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
When building a project with adapter-node, we end up with duplicated code. That's because we take the Vite output (which bundles @sveltejs/kit code) and point the built adapter-node files (which also bundles SvelteKit code, via @sveltejs/kit/node) at it.
This is mostly harmless, but it results in a bug when a request body exceeds BODY_SIZE_LIMIT — because of a failed instanceof SvelteKitError check (the error is an instance of the SvelteKitError class defined in the adapter-node bundle, but the instanceof check happens inside the Vite bundle), the wrong status/message are passed to handleError.
There are three possible angles of attack that I can see:
build stuff in such a way that duplication is avoided. This is the correct solution, but I'm not immediately sure how we'd make that work. we could conceivably exclude @sveltejs/kit from the Vite bundle, but then adapters would in many cases need to be responsible for bundling it themselves
allow adapters to influence the Vite config somehow (i.e. specify an entry point that's defined inside the adapter, with a special module ID that points to the default server entry point)
the cheap and nasty solution which I hope we avoid — duck typing SvelteKitError. This would just mask the problem instead of solving it
Would shipping adapter-node unbundled help with this? (We had previously tried doing that so that we could update the undici version people were using simply by updating the dependency in Kit, rather than needing to republish the adapter to bundle the new version into its shims code - but that's now unneeded since we can just rely on the version of undici that comes with Node.) However, we had to revert that because of a bug in Rollup - rollup/rollup#4708. I'm not sure what our other options are.
Describe the bug
When building a project with
adapter-node
, we end up with duplicated code. That's because we take the Vite output (which bundles@sveltejs/kit
code) and point the builtadapter-node
files (which also bundles SvelteKit code, via@sveltejs/kit/node
) at it.This is mostly harmless, but it results in a bug when a request body exceeds
BODY_SIZE_LIMIT
— because of a failedinstanceof SvelteKitError
check (the error is an instance of theSvelteKitError
class defined in theadapter-node
bundle, but theinstanceof
check happens inside the Vite bundle), the wrong status/message are passed tohandleError
.There are three possible angles of attack that I can see:
@sveltejs/kit
from the Vite bundle, but then adapters would in many cases need to be responsible for bundling it themselvesSvelteKitError
. This would just mask the problem instead of solving itReproduction
https://github.com/Rich-Harris/adapter-node-repro
Logs
No response
System Info
Severity
annoyance
Additional Information
No response
The text was updated successfully, but these errors were encountered: