Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Errors with clean T3 install #1961

Open
ScottyMaher opened this issue Aug 10, 2024 · 14 comments · May be fixed by #1969
Open

bug: Errors with clean T3 install #1961

ScottyMaher opened this issue Aug 10, 2024 · 14 comments · May be fixed by #1969

Comments

@ScottyMaher
Copy link

Provide environment information

System:
OS: Windows 10 10.0.19045
CPU: (8) x64 Intel(R) Core(TM) i7-3770K CPU @ 3.50GHz
Memory: 5.50 GB / 15.89 GB
Binaries:
Node: 20.10.0 - C:\Program Files\nodejs\node.EXE
bun: 1.1.22 - ~.bun\bin\bun.EXE

"ct3aMetadata": {
"initVersion": "7.36.2"
}

Describe the bug

  1. Create a completely fresh T3 app.
  2. Fix invalid environment variables:
NEXTAUTH_SECRET="sample"
NEXTAUTH_URL="http://localhost:3000"

# Next Auth Discord Provider
DISCORD_CLIENT_ID="placeholder"
DISCORD_CLIENT_SECRET="placeholder"
  1. Literally just open or refresh the localhost site in browser:

[TRPC] post.getLatest took 153ms to execute
A query that was dehydrated as pending ended up rejecting. [[["post","getLatest"],{"type":"query"}]]: TRPCError: UNAUTHORIZED; The error will be redacted in production builds
Error: redacted
at eval (webpack-internal:///(rsc)/./node_modules/@tanstack/query-core/build/modern/hydration.js:37:31) {
digest: '1184500366'
}
GET / 200 in 8406ms
⨯ Internal error: Error: redacted
at eval (./node_modules/@tanstack/query-core/build/modern/hydration.js:37:31)
digest: "1184500366"
⨯ unhandledRejection: Error: redacted
at eval (webpack-internal:///(rsc)/./node_modules/@tanstack/query-core/build/modern/hydration.js:37:31) {
digest: '1184500366'
}
⨯ unhandledRejection: Error: redacted
at eval (webpack-internal:///(rsc)/./node_modules/@tanstack/query-core/build/modern/hydration.js:37:31) {
digest: '1184500366'
}

Reproduction repo

It's a fresh create t3-app@latest, with only the .env changed as described

To reproduce

◇ Will you be using TypeScript or JavaScript?
│ TypeScript

◇ Will you be using Tailwind CSS for styling?
│ Yes

◇ Would you like to use tRPC?
│ Yes

◇ What authentication provider would you like to use?
│ NextAuth.js

◇ What database ORM would you like to use?
│ None (I also tried with Prisma)

◇ Would you like to use Next.js App Router?
│ Yes

Additional information

I tried GPTing my way to a solution, but it was not helpful.

@lorenzobandini
Copy link

lorenzobandini commented Aug 10, 2024

I have the same errors

@lorenzocorallo
Copy link

I'm getting something very similar (fresh setup with tRPC, NextAuth, Drizzle)

[TRPC] post.hello took 373ms to execute
[TRPC] post.getLatest took 120ms to execute
A query that was dehydrated as pending ended up rejecting. [[["post","getLatest"],{"type":"query"}]]: TRPCError: RequestInit: duplex option is required when sending a body.; The error will be redacted in production builds
 ⨯ Internal error: Error: redacted
    at eval (./node_modules/.pnpm/@[email protected]/node_modules/@tanstack/query-core/build/modern/hydration.js:37:31)
digest: "2433427594"
Error: redacted
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@[email protected]/node_modules/@tanstack/query-core/build/modern/hydration.js:37:31) {
  digest: '2433427594'
}

@lorenzocorallo
Copy link

lorenzocorallo commented Aug 11, 2024

I'm getting something very similar (fresh setup with tRPC, NextAuth, Drizzle)

[TRPC] post.hello took 373ms to execute
[TRPC] post.getLatest took 120ms to execute
A query that was dehydrated as pending ended up rejecting. [[["post","getLatest"],{"type":"query"}]]: TRPCError: RequestInit: duplex option is required when sending a body.; The error will be redacted in production builds
 ⨯ Internal error: Error: redacted
    at eval (./node_modules/.pnpm/@[email protected]/node_modules/@tanstack/query-core/build/modern/hydration.js:37:31)
digest: "2433427594"
Error: redacted
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@[email protected]/node_modules/@tanstack/query-core/build/modern/hydration.js:37:31) {
  digest: '2433427594'
}

I succeeded to fix my issue by re-creating the project via an older version of t3-app, in particular the 7.34.0.
I think that the issue is related to the changes introduced in the PR #1932

@Guria
Copy link

Guria commented Aug 13, 2024

I was able to fix it in 7.36.2 by adding await to getLatest.prefetch.
But I am not sure that it is a proper solution since it gives a different behaviour that potentially can be unwanted.

void await api.post.getLatest.prefetch();

@eltonstewart
Copy link

that worked for me too @Guria

@ryanhell
Copy link

can confirm adding await to line #11 of page.tsx inside the app folder; also worked for me to eliminate this error message. Will check back to see if there is any new information..

@Guria
Copy link

Guria commented Aug 16, 2024

@eltonstewart @ryanhell Please don't treat it as long term fix.
Adding await here changes expected behaviour. General idea is just trigger getting result at early stage, but don't block page loading and return Suspense fallback.

This issue still requires investigation and proper long term fix. Personally I decided to bootstrap with 7.34 version.

@NightClover-code
Copy link

Just had this exact same error and @Guria's temporary fix works for me.

@Guria
Copy link

Guria commented Aug 19, 2024

@eltonstewart @ryanhell @NightClover-code @ScottyMaher @lorenzocorallo
can you share which DB adapter have you used? Drizzle or Prisma?

@lorenzocorallo
Copy link

@eltonstewart @ryanhell @NightClover-code @ScottyMaher @lorenzocorallo

can you share which DB adapter have you used? Drizzle or Prisma?

I'm using Drizzle with a Turso database

@Guria
Copy link

Guria commented Aug 19, 2024

Hmm. With latest 7.37 I have this issue with Postgres + Prisma, and no issue with Postgres + Drizzle.

@Guria
Copy link

Guria commented Aug 19, 2024

Ok, I've found the descrepancy.
One template use getLatest: protectedProcedure.query and another one getLatest: publicProcedure.query.
So proper solution is not to prefetch getLatest in signed out state.
I will prepare a fix for affected templates.

Guria added a commit to Guria/create-t3-app that referenced this issue Aug 19, 2024
Fixes t3-oss#1961

Fix the issue with errors on a fresh T3 app install by changing `getLatest` to use `publicProcedure` instead of `protectedProcedure`.

* **cli/template/extras/src/server/api/routers/post/with-auth.ts**
  - Change `getLatest` to use `publicProcedure` instead of `protectedProcedure`.
* **cli/template/extras/src/server/api/routers/post/with-auth-prisma.ts**
  - Change `getLatest` to use `publicProcedure` instead of `protectedProcedure`.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/t3-oss/create-t3-app/issues/1961?shareId=XXXX-XXXX-XXXX-XXXX).
Guria added a commit to Guria/create-t3-app that referenced this issue Aug 19, 2024
Fixes t3-oss#1961

Add condition to prefetch `getLatest` only if the user is authenticated.

* Modify `cli/template/extras/src/app/page/with-auth-trpc-tw.tsx` to add a condition to prefetch `getLatest` only if the user is authenticated.
* Modify `cli/template/extras/src/app/page/with-auth-trpc.tsx` to add a condition to prefetch `getLatest` only if the user is authenticated.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/t3-oss/create-t3-app/issues/1961?shareId=XXXX-XXXX-XXXX-XXXX).
Guria added a commit to Guria/create-t3-app that referenced this issue Aug 19, 2024
Fixes t3-oss#1961

Add condition to prefetch `getLatest` only if the user is authenticated.
Guria added a commit to Guria/create-t3-app that referenced this issue Aug 19, 2024
Fixes t3-oss#1961

Add condition to prefetch `getLatest` only if the user is authenticated.
Guria added a commit to Guria/create-t3-app that referenced this issue Aug 20, 2024
…ss#1961)

closes t3-oss#1961

Add condition to prefetch `getLatest` only if the user is authenticated.
@electroheadfx
Copy link

I have the same issue !

@Guria
Copy link

Guria commented Sep 3, 2024

@electroheadfx just make prefetch conditional based on session. See #1969

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants