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
- Create a completely fresh T3 app.
- Fix invalid environment variables:
NEXTAUTH_SECRET="sample"
NEXTAUTH_URL="http://localhost:3000"
# Next Auth Discord Provider
DISCORD_CLIENT_ID="placeholder"
DISCORD_CLIENT_SECRET="placeholder"
- 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
- Align all templates to use publicProcedure for `getLatest` method Fixes #1961 Fix the issue with errors on a fresh T3 app install by changing `getLatest` to use `publicProcedure` instead of `protect... — committed to Guria/create-t3-app by Guria 2 years ago
- fix prefetch in auth templates Fixes #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 condit... — committed to Guria/create-t3-app by Guria 2 years ago
- fix issue with prefetch protected procedure in auth templates Fixes #1961 Add condition to prefetch `getLatest` only if the user is authenticated. — committed to Guria/create-t3-app by Guria 2 years ago
- fix issue with prefetch protected procedure in auth templates Fixes #1961 Add condition to prefetch `getLatest` only if the user is authenticated. — committed to Guria/create-t3-app by Guria 2 years ago
- fix: conditional prefetch protected procedure in auth templates (#1961) closes #1961 Add condition to prefetch `getLatest` only if the user is authenticated. — committed to Guria/create-t3-app by Guria 2 years ago
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.
@electroheadfx just make prefetch conditional based on session. See #1969
Ok, I’ve found the descrepancy. One template use
getLatest: protectedProcedure.queryand another onegetLatest: publicProcedure.query. So proper solution is not to prefetchgetLatestin 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.