Unexpected Behavior with Unused Server Function in TanStack Start
Hi everyone!
I’m facing an issue where an unused function is causing my application to misbehave. Specifically, when I include the following
authenticateUserWithoutAPI
function in my code, even if I don’t call it in any beforeLoad or other route handlers, it causes problems like:
1. The Clerk sign-in component not rendering.
2. The TanStack Router dev tools disappearing.
I have in one file functions/users.ts
this:
If I comment out function authenticateUserWithoutAPI
entirely, everything works as expected. I’m not using it anywhere directly, so I’m confused why its presence alone is affecting the behavior of my app. I only use authenticateUser
in beforeLoad. I suppose the problem is using database in function directly. If I use it in "createServerFn" it's okay.
Has anyone experienced this, or is there something in TanStack Start that might be causing this issue? What Am I missing?
Important to mention the problem is in development environment.
Thank you, in advance.1 Reply
firm-tanOP•9mo ago
I just found out, if I make this function private it works. (That means clerk components are shown.)
Additional findings that I don't understand.
If I define beforeLoad like this:
The Clerk sign-in component renders, and the TanStack Router dev tools work as expected.
However, if I slightly modify the function by removing the const result assignment::
The Clerk sign-in component stops rendering, and the TanStack Router dev tools disappear.