-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENV BODY_SIZE_LIMIT=0 throws error "Content-length of 337 exceeds limit of 0 bytes." #11381
Comments
I've also experienced this bug. We have a need to upload images to the backend and after upgrading to sveltekit v2; settings the |
Are there any workarounds to fix this issue or do I have to set the BODY_SIZE_LIMIT to a large value to ignore this issue? |
Looking at the code, pretty much. Just set it to an arbitrarily high value and continue to let your custom check in |
its strange that even when I set BODY_SIZE_LIMIT= to a very large number Its still sees it as 0 |
There appear to be two ways to address this, and I don't have a strong opinion about which is better. One is to update the @benmccann Do you have thoughts about that? I'm not sure to what extent |
While |
If it's easier to make it an int than undefined for some reason we could also use |
Untested, but I think just a diff --git a/packages/adapter-node/src/handler.js b/packages/adapter-node/src/handler.js
index dcb478f5e..4812ec9ff 100644
--- a/packages/adapter-node/src/handler.js
+++ b/packages/adapter-node/src/handler.js
@@ -19,7 +19,7 @@ const address_header = env('ADDRESS_HEADER', '').toLowerCase();
const protocol_header = env('PROTOCOL_HEADER', '').toLowerCase();
const host_header = env('HOST_HEADER', 'host').toLowerCase();
const port_header = env('PORT_HEADER', '').toLowerCase();
-const body_size_limit = parseInt(env('BODY_SIZE_LIMIT', '524288'));
+const body_size_limit = parseInt(env('BODY_SIZE_LIMIT', '524288')) || undefined;
const dir = path.dirname(fileURLToPath(import.meta.url));
would suffice then. |
Oh, unless what you were proposing was that someone run the adapted app with I think it makes sense to keep the same runtime API for adapted apps as we had before - we arguably could change it now because this particular feature was already not working since 2.0, but it seems nicer to fix it and return to the old API. |
It looks like it currently disables it if you set any non-numeric value like |
Hm. I think |
Yeah, probably better to have the adapter explicitly convert from |
If we're making breaking changes then I'd sooner we use
...and error on anything that results in That seems like the only sensible alternative to reinstating the status quo ante, to me |
I may be biased as the author of #11574, but I think that for now what would be best is to merge that in so that we have a version that removes the unintended breaking change between v1 and v2. And then after that we can decide whether we want to switch the env var handling, when we would want to release that breaking change, what we might want to bundle it with, etc. |
Does it really matter if a breaking change was intended or not? I think what matters is that it's documented |
I'm inclined to agree with @Conduitry — let's just fix the regression for now so that people's apps work again. We can then figure out what breaking changes we actually want at leisure. Not sure what's so strange about allowing arbitrary number expressions — using hex or (especially) exponential notation in this context seems reasonable to me |
Describe the bug
Since this change https://github.com/sveltejs/kit/pull/11289/files#diff-4fd596e614892c76109d32e8f58ad17b3e874414d798603c12f63669db7399d3R40
we cannot set the limit to unlimited.
The docs say to set it to 0 https://kit.svelte.dev/docs/adapter-node#environment-variables-bodysizelimit
but 0 is not undefined and as such it's throwing the error.
Reproduction
await request_event.request.text();
Logs
No response
System Info
Severity
blocking an upgrade
Additional Information
No response
The text was updated successfully, but these errors were encountered: