You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Start: SSR context loss due to dependency externalization #4409
Packages installed in node_modules rely on sharing a server context with the main application, such as using AsyncLocalStorage for request-scoped data, auth, or other per-request state. If Vite externalizes these packages during SSR (its default behavior), they may be loaded in a separate context, causing them to lose access to the shared server state.
This can result in runtime errors like:
Error: No HTTPEvent found in AsyncLocalStorage. Make sure you are using the functionwithin the server runtime.
at getEvent (node_modules/@tanstack/start-server-core/dist/esm/h3.js:30:11)
...
Temporary Workaround:
Add the affected package to the ssr.noExternal option in your vite.config.ts file:
Install Clerk SDK with devinxi support (npm i @clerk/tanstack-react-start@0.17.0-snapshot.v20250611045520 --save-exact)
Run npm run dev
Check console
or visit the codesandbox link
Expected behavior
Packages that depend on shared server context should function correctly during SSR, with no loss of context or unexpected errors, even if they are installed in node_modules.
@wobsoriano Out of interest, even with the noExternal, the SignedIn and SignedOut work, but the UserButton, and SignInButton don't render, and SignOutButton renders but does nothing. Is this expected at the moment while this issue is being sorted out?
@wobsoriano Out of interest, even with the noExternal, the SignedIn and SignedOut work, but the UserButton, and SignInButton don't render, and SignOutButton renders but does nothing. Is this expected at the moment while this issue is being sorted out?
Started from scratch and added everything back in one at a time. Looks like it was lingui integration based on their tanstack starter that was causing Clerk to fail.
@depsimon I just tried out Tanstack Start for the first time today using the start-clerk-basic example, and I encountered the same error @wobsoriano mentioned without modifying anything in the example. I believe you'll see the same error by just going to the example's StackBlitz link.
What is the recommended fix for this? Is it to apply the ssr. noExternal config, or is a more drastic change required or better?
We have a project which was based on this starter: https://clerk.com/docs/quickstarts/tanstack-react-start
We have issues with FOUC and upgrading to newer versions of tanstack.
The tanstack Clerk starter is quite different (vite, no vinxi).
I understand this is beta but is there a timeline for aligning the starter kits? Or getting the Clerk one using the latest Tanstack version?
We have a project which was based on this starter: https://clerk.com/docs/quickstarts/tanstack-react-start
We have issues with FOUC and upgrading to newer versions of tanstack.
The tanstack Clerk starter is quite different (vite, no vinxi).
I understand this is beta but is there a timeline for aligning the starter kits? Or getting the Clerk one using the latest Tanstack version?
@tomleadbetter I believe the plan was always to move from vinxi to vite, so I believe the Clerk starter is newer and more conformed to the potential official version.
@depsimon I just tried out Tanstack Start for the first time today using the start-clerk-basic example, and I encountered the same error @wobsoriano mentioned without modifying anything in the example. I believe you'll see the same error by just going to the example's StackBlitz link.
What is the recommended fix for this? Is it to apply the ssr. noExternal config, or is a more drastic change required or better?
Thanks @wobsoriano. Any ideas about this issue in the Clerk example?
@depsimon I just tried out Tanstack Start for the first time today using the start-clerk-basic example, and I encountered the same error @wobsoriano mentioned without modifying anything in the example. I believe you'll see the same error by just going to the example's StackBlitz link.
What is the recommended fix for this? Is it to apply the ssr. noExternal config, or is a more drastic change required or better?
Thanks @wobsoriano. Any ideas about this issue in the Clerk example?
Encountered the same issue with the tanstack form SSR guide, curious to know if you’ve found a fix.
@Earnstein Did you get this fixed somehow? I'm kind of confused, as I get the same error message and this issue was closed as completed last week but I still get the error with everything updated to the latest version.
@schiller-manuel I tried setting up a minimal example on Stackblitz with the tanstack libraries I use for my project. Even before getting to set up a basic form to reproduce my issue I get the aforementioned error message about AsyncLocalStorage. I'm not sure if I made a mistake during set up or if there is an underlying issue in one of the libraries (I guess it's the former, otherwise there would probably be many more open issues about this): https://stackblitz.com/edit/vitejs-vite-o7sovvfn
Activity
solace commentedon Jun 13, 2025
@wobsoriano Out of interest, even with the
noExternal, theSignedInandSignedOutwork, but theUserButton, andSignInButtondon't render, andSignOutButtonrenders but does nothing. Is this expected at the moment while this issue is being sorted out?solace commentedon Jun 15, 2025
Started from scratch and added everything back in one at a time. Looks like it was lingui integration based on their tanstack starter that was causing Clerk to fail.
depsimon commentedon Jun 18, 2025
@solace I just updated the lingui example here, let me know if you have any issues with it
vcheeze commentedon Jun 19, 2025
@depsimon I just tried out Tanstack Start for the first time today using the
start-clerk-basicexample, and I encountered the same error @wobsoriano mentioned without modifying anything in the example. I believe you'll see the same error by just going to the example's StackBlitz link.What is the recommended fix for this? Is it to apply the
ssr. noExternalconfig, or is a more drastic change required or better?schiller-manuel commentedon Jun 20, 2025
@vcheeze this is just caused by stackblitz not support async local storage.
thereis commentedon Jun 20, 2025
I got this error as well in localhost while trying to use with orpc, this happens when I import
getWebRequest.schiller-manuel commentedon Jun 20, 2025
@thereis can you please share a complete reproducer?
vcheeze commentedon Jun 21, 2025
@schiller-manuel same here - I just ran the command to create a new project using the template, and got the same error on localhost.
mags-sully commentedon Jun 22, 2025
The ssr noexternal workaround for clerk fixes my local dev issue as well
tomleadbetter commentedon Jun 24, 2025
We have a project which was based on this starter: https://clerk.com/docs/quickstarts/tanstack-react-start
We have issues with FOUC and upgrading to newer versions of tanstack.
The tanstack Clerk starter is quite different (vite, no vinxi).
I understand this is beta but is there a timeline for aligning the starter kits? Or getting the Clerk one using the latest Tanstack version?
vcheeze commentedon Jun 24, 2025
@tomleadbetter I believe the plan was always to move from vinxi to vite, so I believe the Clerk starter is newer and more conformed to the potential official version.
tomleadbetter commentedon Jun 24, 2025
Thanks @vcheeze
I'll start with a clean project and see what happens.
tomleadbetter commentedon Jun 24, 2025
@wobsoriano @vcheeze
this repo https://github.com/clerk/clerk-tanstack-react-start-quickstart still uses vinxi. Am I in the right place?
depsimon commentedon Jun 24, 2025
It's still in a branch I believe.
tomleadbetter commentedon Jun 24, 2025
Thanks @depsimon
I'll keep an eye on the situation then rather than dive into it. Looks like a few moving parts.
wobsoriano commentedon Jun 24, 2025
That branch is now merged 👍🏼
vcheeze commentedon Jun 24, 2025
Thanks @wobsoriano. Any ideas about this issue in the Clerk example?
wobsoriano commentedon Jun 24, 2025
I'm updating the starter here #4392
kusiewicz commentedon Jun 26, 2025
FYI guys the same problem occurs when I'm using
@tanstack/react-forms.I get the same error, and stack trace points to tanstack-forms.
Suver1 commentedon Jul 6, 2025
I got the same error when following the
@tanstack/react-formsSSR guide with TanStack Start, along with a few TS errors (see README) in this minimal example: https://stackblitz.com/~/github.com/Suver1/tanstack-start-with-form-bugEarnstein commentedon Jul 21, 2025
Encountered the same issue with the tanstack form SSR guide, curious to know if you’ve found a fix.
fix: fix start vite plugin during dev and prod
MrBlue9 commentedon Jul 27, 2025
@Earnstein Did you get this fixed somehow? I'm kind of confused, as I get the same error message and this issue was closed as completed last week but I still get the error with everything updated to the latest version.
schiller-manuel commentedon Jul 27, 2025
@MrBlue9 can you please create a new GitHub issue including a complete reproducer?
MrBlue9 commentedon Jul 28, 2025
@schiller-manuel I tried setting up a minimal example on Stackblitz with the tanstack libraries I use for my project. Even before getting to set up a basic form to reproduce my issue I get the aforementioned error message about AsyncLocalStorage. I'm not sure if I made a mistake during set up or if there is an underlying issue in one of the libraries (I guess it's the former, otherwise there would probably be many more open issues about this): https://stackblitz.com/edit/vitejs-vite-o7sovvfn
yusoofsh commentedon Dec 17, 2025
For anyone end up here and using Tanstack Start, do:
fix(web): bundle all SSR deps to fix Node.js production runtime
fix(web): bundle all SSR deps to fix Node.js production runtime (#194)