Repository navigation
ref(bun): Use the shared request handler wrapper for Bun.serve - #25587
Conversation
isaacs
added this pull request to stack #25589
October 20, 2026 22:30
Contributor
size-limit report 📦Compared: a89acfb (PR test merge using develop at fb0508a) Against: b3e0c9e (develop) · base run #63030
|
isaacs
force-pushed
the
isaacschlueter/js-3975-share-one-request-handler-wrapper-across-denoserve-bunserve-b
branch
from
October 21, 2026 00:54
429f84b to
7b98f66
Compare
isaacs
marked this pull request as ready for review
October 21, 2026 00:55
isaacs
requested review from
JPeer264 and
andreiborza
and removed request for
a team
October 21, 2026 00:55
isaacs
force-pushed
the
isaacschlueter/js-3975-share-one-request-handler-wrapper-across-denoserve-bunserve-b
branch
from
October 21, 2026 01:07
7b98f66 to
2d4292b
Compare
isaacs
requested review from
nicohrubec and
s1gr1d
and removed request for
a team
October 21, 2026 01:13
isaacs
force-pushed
the
isaacschlueter/js-3975-share-one-request-handler-wrapper-across-denoserve-bunserve-b
branch
from
October 21, 2026 01:13
2d4292b to
65c97e6
Compare
isaacs
force-pushed
the
isaacschlueter/js-3975-share-one-request-handler-wrapper-across-denoserve-bunserve-b
branch
3 times, most recently
from
October 21, 2026 04:14
339b64f to
c2a1219
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit c2a1219. Configure here.
isaacs
force-pushed
the
isaacschlueter/js-3975-share-one-request-handler-wrapper-across-denoserve-bunserve-b
branch
from
October 21, 2026 14:16
c2a1219 to
7e1f64d
Compare
Contributor
Optional E2E testsSome optional checks were not successful. They do not block the merge. 18 failing, 41 successful. See the run.
Successful checks
|
isaacs
force-pushed
the
isaacschlueter/js-3975-share-one-request-handler-wrapper-across-denoserve-bunserve-b
branch
from
October 21, 2026 17:13
7e1f64d to
c8a8ff5
Compare
isaacs
force-pushed
the
isaacschlueter/js-3975-share-one-request-handler-wrapper-across-denoserve-bunserve-b
branch
from
October 21, 2026 17:28
c8a8ff5 to
9a24fd9
Compare
isaacs
force-pushed
the
isaacschlueter/js-3975-share-one-request-handler-wrapper-across-denoserve-bunserve-b
branch
from
October 21, 2026 18:28
7dda93e to
bcab37f
Compare
isaacs
force-pushed
the
isaacschlueter/js-3975-share-one-request-handler-wrapper-across-denoserve-bunserve-b
branch
from
October 21, 2026 18:37
bcab37f to
e6dcb2a
Compare
Moves `Bun.serve` onto `wrapServerRequestHandler`, which `Deno.serve` uses since the previous PR. Bun keeps only what is unique to it: the patches for `fetch`, `routes` and `server.reload`, the route template, the route parameters, and the socket address from `server.requestIP()`. Its copy of the stream monitor moves out, because the wrapper uses the same code from `@sentry/server-utils`. The wrapper gets two optional fields for this. `routeName` passes the matched route to core's span helper, which sets `http.route`, the `route` source and the span name. `attributes` adds span attributes that only the runtime knows, here `url.path.parameter.*`. Bun built its own span attributes, which did not follow the Sentry conventions for `http.server` spans. The conventions say that server instrumentation sets the matched route in `http.route`, and that `url.template` is for `http.client` spans and client-side routing. The host goes in `server.address`, as on Node, Deno and Cloudflare. So Bun spans change: - `url.template` becomes `http.route`. Routes without parameters now also get `http.route` and the `route` source. - `url.domain` becomes `server.address`. - A request to `/` gets the `route` source and the name `GET /`, as on the other runtimes, because the path is already low cardinality. - Spans also get `user_agent.original` and `http.request.body.size`. - Errors in `OPTIONS` and `HEAD` requests now carry the request data. The wrapper now also keeps every `Set-Cookie` header of a response. `Headers.forEach` lists each one on its own, so a plain dict kept only the last one. This fixes Deno too, and Cloudflare once it moves. Part of #25577 Part of JS-3975 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
isaacs
force-pushed
the
isaacschlueter/js-3975-share-one-request-handler-wrapper-across-denoserve-bunserve-b
branch
from
October 21, 2026 18:40
e6dcb2a to
7c3ad11
Compare
This branch has not been deployed
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.

Moves
Bun.serveontowrapServerRequestHandler, whichDeno.serveuses since the previous PR. Bun keeps only what is unique to it: the patches forfetch,routesandserver.reload, the route template, the route parameters, and the socket address fromserver.requestIP(). Its copy of the stream monitor moves out, because the wrapper uses the same code from@sentry/server-utils.The wrapper gets two optional fields for this.
routeNamepasses the matched route to core's span helper, which setshttp.route, theroutesource and the span name.attributesadds span attributes that only the runtime knows, hereurl.path.parameter.*.Bun built its own span attributes, which did not follow the Sentry conventions for
http.serverspans. The conventions say that server instrumentation sets the matched route inhttp.route, and thaturl.templateis forhttp.clientspans and client-side routing. The host goes inserver.address, as on Node, Deno and Cloudflare. So Bun spans change:url.templatebecomeshttp.route. Routes without parameters now also gethttp.routeand theroutesource.url.domainbecomesserver.address./gets theroutesource and the nameGET /, as on the other runtimes, because the path is already low cardinality.user_agent.originalandhttp.request.body.size.OPTIONSandHEADrequests now carry the request data.The wrapper now also keeps every
Set-Cookieheader of a response.Headers.forEachlists each one on its own, so a plain dict kept only the last one. This fixes Deno too, and Cloudflare once it moves.Part of #25577
Part of JS-3975