Clerk convex logic throws an error every first-time I save while running dev server
I consistently see the function provided on the Clerk+Convex documentation throw on first save, when any convex files have been modified. If I CMD+S again (without file changes) I see the happy message. Odd - I'm just now noticing any time there's an error, the time on save is significantly higher:
β 21:52:06 Convex functions ready! (991.28ms) 6/3/2025, 9:52:06 PM [CONVEX Q(projects:fetchProjects)] Uncaught Error: Can't get current user at getCurrentUserOrThrow (../../convex/users.ts:57:9) at async handler (../convex/projects.ts:10:15) β 21:52:26 Convex functions ready! (394.91ms) β 21:52:32 Convex functions ready! (379.47ms) β 21:52:40 Convex functions ready! (947.86ms) 6/3/2025, 9:52:40 PM [CONVEX Q(projects:fetchProjects)] Uncaught Error: Can't get current user at getCurrentUserOrThrow (../../convex/users.ts:57:9) at async handler (../convex/projects.ts:10:15)Any thoughts why? The functionality of the Clerk webhook + seeding the DB works great, annoying to see these errors on the console though π Below is the code from the docs that's throwing.
18 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
Yeah, here is more fuel to that fire -
hit CMD+S a few times in a row, no change- quick turn.
Added a simple LOC to an unrelated file (not to users.ts or projects.ts) and this throws, also took longer.
hit CMD+S a few times again, no change- quick turn.
Removed the simple LOC from that unrelated file (not users.ts or projects.ts) and it throws again, also took longer.

Morning friends - any thoughts on this one? π
I need to see more code to understand what's happening here. The query could be rerun by your client depending on how your local dev server watch is working. Convex will only rerun if something about the query changes, could be a helper function, or a shared dependency.
Can't get current user def means you don't have a user. Where are you calling the function from? Any server side/middleware calls? If it's client, are you skipping until you have an authenticated signal from
isAuthenticated
or the Authenticated component?That's just it - this is calling when my frontend is completely turned off.
so I don't have a damn clue what's calling these functions to run haha!
Whatβs your framework
tanstack start
(not alpha branch)
It's definitely being triggered by your code, maybe a zombie process still running a dev server or something? At any rate, I'd search the codebase for fetchProject and catalog everywhere it's being called. You can log from each call site to figure out where it's being called from.
I know these are very elementary debugging steps, but it's what I'd do next personally.
I'll look again - but quite honestly I'd be shocked... this is a brand new function that hasn't been integrated into the app yet. I'm only now switching to convex π
Yeah I understand, but you're also in mystery territory, so whatever the culprit is will be a surprise. Somewhere something is calling this function, and Convex won't call your functions by itself. I'd grep "fetchProjects" across the codebase to find the culprit.
does convex try to analyze or run anything on save when running convex dev server that might be kicking these off?
It doesn't run functions. Maybe if you had a top level expression in one of your convex files that executes a Convex function, but you would see that if you grepped 'fetchProjects'
Did you grep and not find anything?
Nothing, just the declaration itself
Iβll keep digging!
Yeah that's super odd. It does sound a little like a zombie process or a tab running outdated code or something
What throws me off is I havenβt changed any of my app code yet.
Where did the code that's running come from, a starter?
Can you briefly walk through the steps you took from not using Convex to your current project state
I began with the clerk convex starter, and then started to write additional APIs for convex.
Will debug more tomorrow, birthday today π»π»
Ayyy happy birthday! π»