TanStackT
TanStack3mo ago
2 replies
developed-pink

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'
Was this page helpful?