Repository navigation
ref(bun): Use the shared request handler wrapper for Bun.serve - #25587
Conversation
size-limit report 📦Compared: ba5e8d5 (PR test merge using develop at 3555c35) Against: ad71ef6 (develop) · base run #63604
|
429f84b to
7b98f66
Compare
7b98f66 to
2d4292b
Compare
2d4292b to
65c97e6
Compare
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.
c2a1219 to
7e1f64d
Compare
Optional E2E testsSome optional checks were not successful. They do not block the merge. 10 not successful, 50 successful. See the run.
Successful checks
|
7e1f64d to
c8a8ff5
Compare
c8a8ff5 to
9a24fd9
Compare
7dda93e to
bcab37f
Compare
bcab37f to
e6dcb2a
Compare
7c3ad11 to
73fdfc2
Compare
14b3a94 to
126af7d
Compare
66ff18b to
20e4d07
Compare
20e4d07 to
36b3b23
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>
36b3b23 to
c68716c
Compare
JPeer264
left a comment
There was a problem hiding this comment.
LGTM, found one regression though.

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