T
TanStack2mo ago
correct-apricot

Multiple Convex calls on SSR with Clerk auth — 5 calls, one unauthorized on refresh

Hi! I’m using TanStack Start + Convex + Clerk following official guides. On client nav, one Convex call works fine. But on a full refresh, I see 5 identical Convex queries, and one fails with ctx.auth.getUserIdentity() = null (UNAUTHORIZED). The failed call has the current timestamp, while the 4 others have older ones since they are cached. Only one TanStack loader runs. If the QueryClient has 0 gcTime this issue do not occur. Is this expected from SSR/hydration, or could it be revalidation causing multiple Convex hits? Any ideas how to prevent duplicates, preventing failed calls, but not killing the gcTime?
10/24/2025, 11:57:47 AM [CONVEX Q(tasks:get)] [LOG] 'TASKS GET - ctx.auth.getUserIdentity():' 'REDACTED'
10/24/2025, 11:57:47 AM [CONVEX Q(tasks:get)] [LOG] 'TASKS GET - ctx.auth.getUserIdentity():' 'REDACTED'
10/24/2025, 11:58:02 AM [CONVEX Q(tasks:get)] [LOG] 'TASKS GET - ctx.auth.getUserIdentity():' null
10/24/2025, 11:58:02 AM [CONVEX Q(tasks:get)] Uncaught Error: UNAUTHORIZED
at handler (../convex/tasks.ts:13:11)

10/24/2025, 11:57:47 AM [CONVEX Q(tasks:get)] [LOG] 'TASKS GET - ctx.auth.getUserIdentity():' 'REDACTED'
10/24/2025, 11:57:47 AM [CONVEX Q(tasks:get)] [LOG] 'TASKS GET - ctx.auth.getUserIdentity():' 'REDACTED'
10/24/2025, 11:57:47 AM [CONVEX Q(tasks:get)] [LOG] 'TASKS GET - ctx.auth.getUserIdentity():' 'REDACTED'
10/24/2025, 11:57:47 AM [CONVEX Q(tasks:get)] [LOG] 'TASKS GET - ctx.auth.getUserIdentity():' 'REDACTED'
10/24/2025, 11:58:02 AM [CONVEX Q(tasks:get)] [LOG] 'TASKS GET - ctx.auth.getUserIdentity():' null
10/24/2025, 11:58:02 AM [CONVEX Q(tasks:get)] Uncaught Error: UNAUTHORIZED
at handler (../convex/tasks.ts:13:11)

10/24/2025, 11:57:47 AM [CONVEX Q(tasks:get)] [LOG] 'TASKS GET - ctx.auth.getUserIdentity():' 'REDACTED'
10/24/2025, 11:57:47 AM [CONVEX Q(tasks:get)] [LOG] 'TASKS GET - ctx.auth.getUserIdentity():' 'REDACTED'
1 Reply
genetic-orange
genetic-orange2mo ago
please ask in #start-questions next time can you show some code? ideally a full project

Did you find this page helpful?