create-t3-app: bug: Errors with clean T3 install

Provide environment information

System: OS: Windows 10 10.0.19045 CPU: (8) x64 Intel® Core™ 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.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17 (7 by maintainers)

Commits related to this issue

Most upvoted comments

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();

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

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.

@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.