Debugging of accidental server code in the client-bundle?
Is there any plan to support a better debugging experience in cases where server side code is accidently included in the client bundle? Right now, I see errors like
Buffer is not defined
but the stacktrace does not reveal anything about where it's actually imported/used. Not sure if it's even possible to make it easier...
Also, is something like .server.ts
planned? Making sure none of the files exports are included in the client bundle?5 Replies
fair-rose•9mo ago
I second this. As a newbie to Start trying to port a basic NextJS app I just spent several hours trying to decipher the errors I was getting and track down where a bit of (unexecuted) server code was getting referenced by the client. A lint rule would be sweet if it was possible
fascinating-indigo•9mo ago
I triple this. The .server.ts syntax from Remix gave me peace of mind I really don't have with other frameworks. I actually had a .server/ folder for proper separation.
rival-black•9mo ago
Fourth 🙂 having also spent time hunting down errors like this
ambitious-aqua•8mo ago
@Johnny did you find out how to fix it?
Just hit this and don't know how to trace which piece of code caused it (it also seems to be cached)
oh.. my bad. I thought that loaders were server side - needed to move everything into a createServerFn
rare-sapphireOP•8mo ago
It's really trial and error...and sometimes a single export can result in server side code being exposing the client bundle.
This has more info: https://github.com/TanStack/router/issues/2783
GitHub
Start - Server Function Middleware Included in Client Bundle · Issu...
Which project does this relate to? Start Describe the bug Calling a serverFn using middleware in the client with useServerFn results in server side code being included in client bundle. I'll tr...