feat(bun): Capture Bun.serve request bodies with maxRequestBodySize - #24233
Open
JosephDoUrden wants to merge 1 commit into
Open
feat(bun): Capture Bun.serve request bodies with maxRequestBodySize#24233JosephDoUrden wants to merge 1 commit into
maxRequestBodySize#24233JosephDoUrden wants to merge 1 commit into
Conversation
Bun.serve handlers never captured request bodies, so dataCollection.httpBodies and maxRequestBodySize did nothing there. Use the same WinterCG helpers as Deno: winterCGRequestToRequestData for normalizedRequest and captureBodyFromWinterCGRequest for the body. bunServerIntegration gets a maxRequestBodySize option, an explicit value wins over httpBodies, GET is skipped. Swapping the hand-built normalizedRequest changes one field: query_string loses the leading "?" (it was URL.search, the helper strips it like Deno, Cloudflare and Node do). Headers are unchanged, both versions lower-case the keys and neither filters at the source, requestDataIntegration does that downstream against dataCollection.httpHeaders.request. The handler wrapper is now async so it always returns a promise, which Bun.serve accepts.
JosephDoUrden
requested review from
JPeer264 and
mydea
and removed request for
a team
September 9, 2026 10:03
Member
|
bugbot run |
Member
|
Thanks a lot for your contributions. I'll let bugbot run over it and once this one is done I'll take a closer look at the PR. |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit e5d499d. Configure here.
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.
yarn lint) & (yarn test).Ports the Deno body capture from #22912 to
Bun.serve. SamemaxRequestBodySizeoption, same default (mediumwhenhttpBodiesincludesincomingRequest, otherwisenone), GET skipped, body read beforecontinueTraceso it lands on the request data. As on Deno an explicitmaxRequestBodySizewins overhttpBodiesin both directions.One side effect:
normalizedRequestnow comes fromwinterCGRequestToRequestData, soquery_stringloses the leading?and isundefinedinstead of""when there is no query. That matches what Deno, Cloudflare and Node already send, and theurl.queryspan attribute Bun was already stripping.The body read is awaited before the handler runs and core caps it at 2s, so a client that opens an upload and stalls holds the handler up to 2s even if the handler never reads the body. Same as Deno and Cloudflare, just new for Bun.
The isolation scope callback had to go async for the body read, so the wrapper returns a promise now.
Bun.serveaccepts either, and every non HEAD/OPTIONS path was already returning one viastartSpan.Tests: 10 new in
bunserver.test.ts, 60/60 green for the package, plus arequest-bodiessuite inbun-integration-tests, 14/14 green.Closes #23884
AI disclosure: AI assistance (Claude) was used for research and to draft the tests. The implementation was written and reviewed by the author.