Title: Share one `Request` handler wrapper across Deno.serve, Bun.serve and Cloudflare · Issue #25577 · getsentry/sentry-javascript · GitHub
Open Graph Title: Share one `Request` handler wrapper across Deno.serve, Bun.serve and Cloudflare · Issue #25577 · getsentry/sentry-javascript
X Title: Share one `Request` handler wrapper across Deno.serve, Bun.serve and Cloudflare · Issue #25577 · getsentry/sentry-javascript
Description: Deno.serve, Bun.serve and Cloudflare each wrap a web-standard (Request) => Response handler. Each has its own copy of the same steps: isolation scope and request data client IP address request body capture continueTrace and the http.serv...
Open Graph Description: Deno.serve, Bun.serve and Cloudflare each wrap a web-standard (Request) => Response handler. Each has its own copy of the same steps: isolation scope and request data client IP address request body...
X Description: Deno.serve, Bun.serve and Cloudflare each wrap a web-standard (Request) => Response handler. Each has its own copy of the same steps: isolation scope and request data client IP address request b...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/25577
X: @github
Domain: github.com
IPv4 address: 140.82.112.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Share one `Request` handler wrapper across Deno.serve, Bun.serve and Cloudflare","articleBody":"Deno.serve, Bun.serve and Cloudflare each wrap a web-standard `(Request) => Response` handler. Each has its own copy of the same steps:\n\n* isolation scope and request data\n* client IP address\n* request body capture\n* `continueTrace` and the `http.server` span\n* span name rules for span streaming\n* response status and headers on the span\n* end the span when a streamed response finishes\n* capture errors that the handler throws\n* request sessions (Deno only)\n\nThe files are `packages/deno/src/wrap-deno-request-handler.ts`,`packages/bun/src/integrations/bunserver.ts` and`packages/cloudflare/src/wrapRequestHandlerWithInit.ts`, about 900 lines together.\n\nThe copies drift. A fix or feature in one runtime does not reach the others. Examples today:\n\n* Bun.serve returns early for `OPTIONS` and `HEAD`, with no error capture. Cloudflare captures errors for them. Deno records sessions for them.\n* Deno and Bun skip body capture for `GET`. Cloudflare skips `GET`, `HEAD` and `OPTIONS`.\n* Deno and Bun each have a `utils/streaming.ts` with a different `monitorStream`. Bun's reads only when the client pulls and captures errors from the stream source. Deno's reads ahead of the client, with no backpressure, and does not capture stream errors. Cloudflare has a third version inline.\n* Deno.serve has sessions and the full option set (#25493, #25496). Bun.serve and Cloudflare do not.\n\nThe shared `ServerRequestOptions` type (getsentry/sentry-javascript#25538) keeps option names in sync, but not behavior.\n\n### **Proposed solution**\n\nAdd a wrapper to `@sentry/server-utils`. That package is internal, so the wrapper can change as runtimes move onto it. Every runtime SDK already depends on it.\n\n```\nexport function wrapServerRequestHandler(\n config: {\n request: Request;\n options: ServerRequestOptions\u003cRequest, Response>;\n origin: string; // e.g. 'auto.http.deno.serve'\n getClientAddress?: () => { address: string; port?: number } | undefined;\n getRouteAttributes?: () => SpanAttributes | undefined; // Bun route templates\n isStreamingResponse?: (response: Response) => boolean | undefined;\n onFinish?: () => void; // Cloudflare flush via waitUntil\n },\n handler: () => Response | Promise\u003cResponse>,\n): Promise\u003cResponse>;\n```\n\nThe wrapper owns every shared step in the list above, and it reads `options` for the shared rules. Each runtime keeps only what is unique to it:\n\n* Deno: reads the address from `Deno.ServeHandlerInfo`, and finds the handler in the `Deno.serve`call forms.\n* Bun: patches `fetch`, `routes` and `server.reload`. Gives route templates and params, and calls `server.requestIP()`.\n* Cloudflare: client init and caching, `cf` context, cloud resource context, the `isStreamingResponse` option, flush through `waitUntil`. It passes `sessions: false`.\n\nOne behavior for all three, taken from core's `node:http` server code (`packages/core/src/integrations/http/server-subscription.ts`), so web and `node:http` match:\n\n* `OPTIONS` and `HEAD`: no span. Still isolate the request, attach request data, record a session and capture errors.\n* Static asset filter: `GET` only.\n* Body capture: skip `GET`, `HEAD` and `OPTIONS`, then apply `ignoreRequestBody`.\n* Streaming: keep Bun's `monitorStream` (no read-ahead, captures source errors) and delete the other two.\n\nPlan for the PR: move one runtime at a time, in separate commits, Deno first because it has the full option set. The existing tests of each runtime must pass with no change, except tests that assert one of the behavior differences above. List those changes in the PR description, because users can see them.","author":{"url":"https://github.com/isaacs","@type":"Person","name":"isaacs"},"datePublished":"2026-10-20T17:09:16Z","url":"https://github.com/getsentry/sentry-javascript/issues/25577"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:192aff75-26da-6de5-97c9-0f27f9ac9447 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C41C:51CB6:1697552:1DE1F2A:6B0415A5 |
| html-safe-nonce | e2f6ce4454aebe4d437d68b285550a8d34e7746c8adb97091b120d5176250243 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNDFDOjUxQ0I2OjE2OTc1NTI6MURFMUYyQTo2QjA0MTVBNSIsInZpc2l0b3JfaWQiOiI0Mzc3NzE1NjgzOTA4MzkyMzU3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | b5f7be179af7461162536ff3461100017629a357fbf1045039d81e12e38acd00 |
| hovercard-subject-tag | issue:5946100604 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/25577/issue_layout |
| twitter:image | https://opengraph.githubassets.com/21164b6021f9f55dbd814feaf6df2a3f836f1f8b8d1ec214aa19b755fdfcf253/getsentry/sentry-javascript/issues/25577 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/21164b6021f9f55dbd814feaf6df2a3f836f1f8b8d1ec214aa19b755fdfcf253/getsentry/sentry-javascript/issues/25577 |
| og:image:alt | Deno.serve, Bun.serve and Cloudflare each wrap a web-standard (Request) => Response handler. Each has its own copy of the same steps: isolation scope and request data client IP address request body... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | isaacs |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width