Open Rich-Harris opened 8 months ago
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 - https://github.com/rollup/rollup/issues/4708. I'm not sure what our other options are.
It's not enough by itself, as Kit is bundled into the Vite output as well. But it would be a necessary first step I think, yeah
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