T
TanStack7mo ago
harsh-harlequin

Bug middleware tanstack-start

Hello, I'm encountering an issue with the middleware. When I use it, no fetch requests are made, and I get this error in the console. I think it might be a bug in TanStack-Start, or maybe I did something wrong? error : vite-browser-exter…:node:async_hooks:3 Uncaught Error: Module "node:async_hooks" has been externalized for browser compatibility. Cannot access "node:async_hooks.AsyncLocalStorage" in client code. See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details. at Object.get (vite-browser-exter…de:async_hooks:3:11)
No description
No description
No description
No description
5 Replies
absent-sapphire
absent-sapphire6mo ago
don't export getSessionToken. it cant be removed then for the client if you need it somewhere else, export it from another file that does not have server functions in it
harsh-harlequin
harsh-harlequinOP6mo ago
It still doesn't work, even if I create a separate file for getSessionToken or use it directly in the middleware
No description
absent-sapphire
absent-sapphire6mo ago
can you provide this as a complete repo?
harsh-harlequin
harsh-harlequinOP6mo ago
I just found my bug; it also came from my beforeLoad in __root.tsx. So, I needed to properly separate the files. Thanks for your help! 😁
absent-sapphire
absent-sapphire6mo ago
what did you do in beforeLoad? Call a server only function ?

Did you find this page helpful?