Repository navigation
feat(cloudflare): Send the trace to the browser in a Server-Timing header - #26774
Conversation
|
bugbot run |
size-limit report 📦Compared: dca3c39 (PR test merge using develop at 84df128) Against: 84df128 (develop) · base run #67650 ✅ Baseline matches: this diff contains only this PR's changes.
|
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 5804743. Configure here.
Optional E2E testsSome optional checks were not successful. They do not block the merge. 2 not successful, 64 successful. See the run.
Successful checks
|
5804743 to
10d471e
Compare
…ader On Node, framework SDKs call addServerTimingTraceHeader so the document response carries the request's trace and the browser pageload continues it. Workers had nothing like it. The shared web Request wrapper now adds the header for clients that turned it on, the same way: only to documents no shared cache stores, keeping an existing sentry-trace entry. @sentry/cloudflare exports addServerTimingTraceHeader. Refs JS-4146 Co-Authored-By: Claude Opus 5.5 <[email protected]>
10d471e to
5bbd695
Compare
JPeer264
left a comment
There was a problem hiding this comment.
I added to concerns, but overall it looks nice
| export { getFinalOptions as _INTERNAL_getFinalOptions } from './options'; | ||
|
|
||
| export { httpServerIntegration } from './integrations/httpServer'; | ||
| export { addServerTimingTraceHeader } from '@sentry/server-utils/request-handler'; |
There was a problem hiding this comment.
l: Is there any benefit for users to use this function? Otherwise I'd suggest to mark this as internal
There was a problem hiding this comment.
It's public on Node too, and a plain Workers app that renders HTML (e.g. Hono JSX) can turn it on to connect the pageload to the server trace. I'd keep it public to match Node.
| return response; | ||
| } catch { | ||
| // Passing the original response as the init keeps its status, status text and headers. | ||
| const copy = new Response(response.body, response); |
There was a problem hiding this comment.
We have enough tests that proof that it isn't an issue, but I still wonder if we have any bad side effects returning a complete new response. Maybe you can stress test your local clanker a little and challenge it.
There was a problem hiding this comment.
The copy only happens when the headers are immutable, so for a response passed straight through from fetch(). The wrapper already copies streamed responses the same way, and new Response(body, response) is how Cloudflare documents changing headers. It drops url, redirected and type, which a returned response doesn't use.
…Workers (#26791) ## What On Workers, `defineCloudflareOptions` from `@sentry/solid/solid2/cloudflare` turns on `addServerTimingTraceHeader` and adds `solidServerTracePropagationIntegration`, so the browser pageload continues the server trace, as it does on Node. The Solid 2 Cloudflare e2e app now runs its trace propagation test. ## Why Stacked on #26774, which adds `addServerTimingTraceHeader` to `@sentry/cloudflare`. Kept apart so each part is easier to review. Refs JS-4146 --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
What
@sentry/cloudflareexportsaddServerTimingTraceHeader(client), like@sentry/node. Once a framework SDK turns it on, document responses carry the request's trace in aServer-Timingheader, so the browser pageload continues the server trace.Why
On Workers, every pageload started a new trace. The header follows the same rules as on Node:
sentry-traceentry is kept.Solid turns it on in a stacked PR.
Closes #26771
Refs JS-4146