Repository navigation
ref(cloudflare): Use the shared request handler wrapper - #25588
Conversation
isaacs
added this pull request to stack #25589
October 20, 2026 22:30
Contributor
size-limit report 📦Compared: bf68211 (PR test merge using develop at 7e6b8ea) Against: f15e256 (develop) · base run #63142
|
isaacs
force-pushed
the
isaacschlueter/js-3975-share-one-request-handler-wrapper-across-denoserve-bunserve-c
branch
from
October 21, 2026 01:06
fc30522 to
5d3ee29
Compare
isaacs
marked this pull request as ready for review
October 21, 2026 01:07
isaacs
requested review from
JPeer264 and
andreiborza
and removed request for
a team
October 21, 2026 01:07
isaacs
force-pushed
the
isaacschlueter/js-3975-share-one-request-handler-wrapper-across-denoserve-bunserve-c
branch
from
October 21, 2026 01:07
5d3ee29 to
7a1874d
Compare
isaacs
requested review from
chargome and
nicohrubec
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-c
branch
from
October 21, 2026 01:13
7a1874d to
9e86e46
Compare
isaacs
force-pushed
the
isaacschlueter/js-3975-share-one-request-handler-wrapper-across-denoserve-bunserve-c
branch
2 times, most recently
from
October 21, 2026 01:20
a650894 to
66b9312
Compare
isaacs
force-pushed
the
isaacschlueter/js-3975-share-one-request-handler-wrapper-across-denoserve-bunserve-c
branch
from
October 21, 2026 04:14
a1a478b to
f0da1bc
Compare
isaacs
force-pushed
the
isaacschlueter/js-3975-share-one-request-handler-wrapper-across-denoserve-bunserve-c
branch
from
October 21, 2026 17:15
f0da1bc to
128c6ee
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 128c6ee. Configure here.
isaacs
force-pushed
the
isaacschlueter/js-3975-share-one-request-handler-wrapper-across-denoserve-bunserve-c
branch
from
October 21, 2026 17:28
128c6ee to
411a6ac
Compare
Contributor
Optional E2E testsSome optional checks were not successful. They do not block the merge. 2 failing, 62 successful. See the run.
Successful checks
|
isaacs
force-pushed
the
isaacschlueter/js-3975-share-one-request-handler-wrapper-across-denoserve-bunserve-c
branch
from
October 21, 2026 18:35
411a6ac to
a18c1c2
Compare
isaacs
force-pushed
the
isaacschlueter/js-3975-share-one-request-handler-wrapper-across-denoserve-bunserve-c
branch
from
October 21, 2026 18:37
a18c1c2 to
f81ddfd
Compare
isaacs
force-pushed
the
isaacschlueter/js-3975-share-one-request-handler-wrapper-across-denoserve-bunserve-c
branch
2 times, most recently
from
October 22, 2026 15:37
14b8f95 to
9ff7d48
Compare
Moves Cloudflare's `wrapRequestHandler` onto `wrapServerRequestHandler`, which `Deno.serve` and `Bun.serve` use since the previous PRs. Cloudflare keeps only what is unique to it: client init, the `cf` and cloud resource contexts, the protocol from `cf.httpProtocol`, the `isStreamingResponse` option, `captureErrors`, and the flush through `waitUntil`, which skips the dispose for a 101 response. The helpers that only the old code used (`captureIncomingRequestBody`, `shouldCreateIncomingRequestSpan`, `getIncomingRequestSpanHooks` and `addRequest`) are gone. `wrapRequestHandler` must run on workers without the `nodejs_compat` flag, such as Shopify Oxygen, and every `@sentry/server-utils` entry loads `node:async_hooks`. So the wrapper moves to a new entry, `@sentry/server-utils/request-handler`, with no Node.js imports. Deno and Bun import it from there too. Cloudflare's module graph test allows this one entry, and a new test in server-utils walks the entry's module graph and fails on any Node.js import. The wrapper gets three optional fields: `isStreamingResponse`, `onDone` (called once when the request is done, with the response if there is one), and a `mechanism` that can be left out to not capture errors. For streamed responses, the shared stream monitor replaces Cloudflare's `TransformStream`. Workers with a compatibility date before 2022-11-30 cannot construct a `ReadableStream` without the `streams_enable_constructors` flag, so the wrapper then ends at handler return, as the `TransformStream` fallback did. The monitor now locks the source body only in `start()`, so the original response stays usable in that case. The wrapper builds the new response from the original one, which keeps `encodeBody: 'manual'`. Visible changes for Cloudflare: - Request spans set `client.address` from `CF-Connecting-IP` (or another forwarding header), as on the other runtimes. This follows `dataCollection.userInfo`, which is `true` by default. - Request spans get the response header attributes, and events get the `response` context. - An error from the source of a streamed response is captured (unless `captureErrors` is `false`), and the span gets an error status. - If the user removed `httpServerIntegration`, request bodies follow `dataCollection.httpBodies`. Before, the SDK attached no body. The minified `withSentry` bundle grows by about 2.4 KB (212,385 to 214,853 bytes), under the 211 KiB limit. Most of it is the request session and client address code, which Cloudflare now shares. Fixes #25577 Fixes 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-c
branch
from
October 22, 2026 20:25
9ff7d48 to
a3bb8f3
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 Cloudflare's
wrapRequestHandlerontowrapServerRequestHandler, whichDeno.serveandBun.serveuse since the previous PRs. Cloudflare keeps only what is unique to it: client init, thecfand cloud resource contexts, the protocol fromcf.httpProtocol, theisStreamingResponseoption,captureErrors, and the flush throughwaitUntil, which skips the dispose for a 101 response. The helpers that only the old code used (captureIncomingRequestBody,shouldCreateIncomingRequestSpan,getIncomingRequestSpanHooksandaddRequest) are gone.wrapRequestHandlermust run on workers without thenodejs_compatflag, such as Shopify Oxygen, and every@sentry/server-utilsentry loadsnode:async_hooks. So the wrapper moves to a new entry,@sentry/server-utils/request-handler, with no Node.js imports. Deno and Bun import it from there too. Cloudflare's module graph test allows this one entry, and a new test in server-utils walks the entry's module graph and fails on any Node.js import.The wrapper gets three optional fields:
isStreamingResponse,onDone(called once when the request is done, with the response if there is one), and amechanismthat can be left out to not capture errors.For streamed responses, the shared stream monitor replaces Cloudflare's
TransformStream. Workers with a compatibility date before 2022-11-30 cannot construct aReadableStreamwithout thestreams_enable_constructorsflag, so the wrapper then ends at handler return, as theTransformStreamfallback did. The monitor now locks the source body only instart(), so the original response stays usable in that case. The wrapper builds the new response from the original one, which keepsencodeBody: 'manual'.Visible changes for Cloudflare:
client.addressfromCF-Connecting-IP(or another forwarding header), as on the other runtimes. This followsdataCollection.userInfo, which istrueby default.responsecontext.captureErrorsisfalse), and the span gets an error status.httpServerIntegration, request bodies followdataCollection.httpBodies. Before, the SDK attached no body.The minified
withSentrybundle grows by about 2.4 KB (212,385 to 214,853 bytes), under the 211 KiB limit. Most of it is the request session and client address code, which Cloudflare now shares.Fixes #25577
Fixes JS-3975