fix: remove Content-Length from virtual file StreamingResponse#8928
Merged
dmadisetti merged 1 commit intomainfrom Mar 30, 2026
Merged
fix: remove Content-Length from virtual file StreamingResponse#8928dmadisetti merged 1 commit intomainfrom
dmadisetti merged 1 commit intomainfrom
Conversation
Closes #8917 ## Summary The `@file/` endpoint set `Content-Length` on a `StreamingResponse`, mixing length-delimited and chunked framing. Starlette's `BaseHTTPMiddleware` re-wraps streaming bodies through memory object streams, which can desynchronize the byte count from the declared length for large responses. This caused h11 `LocalProtocolError` when serving large anywidget ESM bundles (~2MB+). Fix: drop the `Content-Length` header so h11 uses chunked transfer encoding instead.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a protocol/framing issue in the server’s virtual file (/@file/) endpoint by ensuring large virtual assets are delivered via streaming without an explicit Content-Length, avoiding h11 LocalProtocolError for large anywidget ESM bundles.
Changes:
- Remove the
Content-Lengthheader from theStreamingResponsereturned byvirtual_file. - Add a regression test asserting that large virtual-file responses do not include
Content-Length.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
marimo/_server/api/endpoints/assets.py |
Stops setting Content-Length on the streaming virtual-file response to avoid h11 framing errors. |
tests/_server/api/endpoints/test_assets.py |
Adds a regression test for large virtual-file streaming responses ensuring Content-Length is not present. |
dmadisetti
approved these changes
Mar 30, 2026
|
🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.21.2-dev89 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #8917
The
@file/endpoint setContent-Lengthon aStreamingResponse, mixing length-delimited and chunked framing. Starlette'sBaseHTTPMiddlewarere-wraps streaming bodies through memory object streams, which can desynchronize the byte count from the declared length for large responses. This caused h11LocalProtocolErrorwhen serving large anywidget ESM bundles (~2MB+).Fix: drop the
Content-Lengthheader so h11 uses chunked transfer encoding instead.