Skip to content
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

feat: add unit suffix support for BODY_SIZE_LIMIT #11680

Merged
merged 4 commits into from
Jun 19, 2024

Conversation

cooolbros
Copy link
Contributor

This PR adds unit suffixes support to the adapter-node BODY_SIZE_LIMIT environment variable.

Currently, achieving large byte values is only achievable with the exact byte value, and using exponents (like 1e6 to be parsed by Number) results in a byte value in base 10.

Nginx and Cloudflare both use base 2 for byte calculations (1024 based):
Nginx (source code): https://hg.nginx.org/nginx/file/default/src/core/ngx_parse.c
Cloudflare (forum question): https://community.cloudflare.com/t/is-max-upload-size-mb-1024-or-1000/239102

Adding unit suffixes to the byte values will make it easier to write and comprehend large byte values, as they can be written such as 100M instead of 104857600

Nginx also supports the size units K and M (https://nginx.org/en/docs/syntax.html) so it would be relevant for Sveltekit to support these units as well


Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: /~https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Edits

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

Copy link

changeset-bot bot commented Jan 19, 2024

🦋 Changeset detected

Latest commit: f0f628b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/adapter-node Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@eltigerchino eltigerchino changed the title adapter-node: Add body size limit units feat: add unit suffix support for BODY_SIZE_LIMIT May 18, 2024
@benmccann benmccann merged commit 6b545e2 into sveltejs:main Jun 19, 2024
9 of 12 checks passed
@github-actions github-actions bot mentioned this pull request Jun 19, 2024
@hyunbinseo
Copy link
Contributor

I am not sure why, but the updated docs is shown in the IDLE_TIMEOUT section.

image

@benmccann
Copy link
Member

thanks. I fixed the bad merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants