Skip to content

fix(storage): Allow uploads above 6 MiB - #472

Open
Bohreromir wants to merge 1 commit into
mainfrom
fix/upload-body-size-limit
Open

Bohreromir wants to merge 1 commit into
mainfrom
fix/upload-body-size-limit

Conversation

@Bohreromir

@Bohreromir Bohreromir commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Description

The storage browser uploads each file in a single request, so the image's BODY_SIZE_LIMIT of 6M capped uploads at 6 MiB. Raise it to 5G; the upload endpoint streams the body to S3, so this does not grow server memory.

A new hook limits all other routes, most of which buffer the body, to max(6 MiB, editable file size + 1 MiB) by Content-Length, before better-auth or any handler reads it. Bodies without Content-Length are rejected with 411.

A body above BODY_SIZE_LIMIT now answers the upload with 413 instead of 502, and the upload modal says the file is too large. Document the matching ingress-nginx body limit.

Docs

Release note

Checklist

Author

  • AI review done, findings addressed
  • Tests added or updated
  • Changelog updated (if the repo keeps one)

Reviewer

  • Useful comments and logging
  • Docs added or updated per the style guide

Acceptance

  • Check for release notes and docs

The storage browser uploads each file in a single request, so the image's
BODY_SIZE_LIMIT of 6M capped uploads at 6 MiB. Raise it to 5G; the upload
endpoint streams the body to S3, so this does not grow server memory.

A new hook limits all other routes, most of which buffer the body, to
max(6 MiB, editable file size + 1 MiB) by Content-Length, before better-auth
or any handler reads it. Bodies without Content-Length are rejected with 411.

A body above BODY_SIZE_LIMIT now answers the upload with 413 instead of 502,
and the upload modal says the file is too large. Document the matching
ingress-nginx body limit.
@github-actions

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 67.59% 9291 / 13746
🔵 Statements 66.5% 12469 / 18748
🔵 Functions 68.37% 2988 / 4370
🔵 Branches 57.55% 5243 / 9109
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/hooks.server.ts 0% 0% 0% 0% 34-202
src/lib/components/storage/modals/upload/UploadModal.svelte 74.04% 47.01% 79.23% 70.03% 96-97, 129, 140-142, 157-159, 166-168, 172-173, 200-202, 217-221, 281-334, 348-350, 363-391, 408, 412, 532-535, 614-625
src/lib/server/request-body-limit.ts 100% 100% 100% 100%
src/lib/server/storage/wrap-provider.ts 88.23% 92.3% 100% 86.66% 33, 39
src/routes/(app)/api/storage/upload/+server.ts 100% 100% 100% 100%
Generated in workflow #1315 for commit b966acc by the Vitest Coverage Report Action

@Bohreromir
Bohreromir marked this pull request as ready for review November 16, 2026 15:17
@Bohreromir Bohreromir moved this to Development: Waiting for Review in Stackable Engineering Nov 16, 2026
@Bohreromir Bohreromir self-assigned this Nov 16, 2026
@labrenbe
labrenbe self-requested a review November 16, 2026 15:55
Comment thread docker/Dockerfile
# buffer the body, are limited to max(6 MiB, editable file size + 1 MiB) by
# src/lib/server/request-body-limit.ts. The E2E app reads this value from here
# (e2e/support/body-size-limit.ts).
ENV BODY_SIZE_LIMIT=5G

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably increase the request timeout for uploads or large uploads might time out after 5 min.

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

Labels

None yet

Projects

Status: Development: Waiting for Review

Development

Successfully merging this pull request may close these issues.

2 participants