fix(react-router): Resolve the Cloudflare entry in Workers and skip trace meta tags in prerendered pages - #24866
Merged
Conversation
JPeer264
added this pull request to stack #24867
September 30, 2026 08:07
Contributor
size-limit report 📦
|
JPeer264
force-pushed
the
jp/react-router-cloudflare-worker-fixes
branch
2 times, most recently
from
October 1, 2026 13:14
0b6e114 to
05f82b1
Compare
…race meta tags in prerendered pages In a Worker build, the Cloudflare Vite plugin resolves with the `browser` condition set, and the exports map lists `browser` first, so `@sentry/react-router` resolved to the client build. `Sentry.startSpan()` and `Sentry.flush()` then compiled to `undefined` in loaders and middleware. The Cloudflare entry is now resolved under the `workerd` condition. On Cloudflare, `react-router build` prerenders pages through the wrapped Worker, so `injectTraceMetaTags` wrote one build-time `sentry-trace` into the static HTML and every visitor continued that trace. The server build capture now also records the `prerender` list, `wrapSentryHandleRequest` registers the capture (on Cloudflare nothing did), and paths from that list get no meta tags. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… skip trace meta tags in prerendered pages Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… skip trace meta tags in prerendered pages Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… skip trace meta tags in prerendered pages Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… skip trace meta tags in prerendered pages Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
JPeer264
force-pushed
the
jp/react-router-cloudflare-worker-fixes
branch
from
October 1, 2026 17:54
ee8e6e3 to
ba877af
Compare
Member
Author
|
bugbot run |
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 ba877af. Configure here.
JPeer264
marked this pull request as ready for review
October 2, 2026 08:49
JPeer264
requested review from
chargome and
nicohrubec
and removed request for
a team
October 2, 2026 08:49
chargome
approved these changes
Oct 2, 2026
47 tasks
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.
Three bugs in
@sentry/react-router, found by running thereact-router-8-frameworke2e suite on workerd and Bun.Cloudflare builds resolve with both the
workerand thebrowsercondition (the Vite plugin setsworkerd, worker, module, browser,wranglersetsworkerd, worker, browser), and the exports map listedbrowserbeforeworker, soworkerwas never reached.import * as Sentry from '@sentry/react-router'in a route got the client build, andSentry.startSpan()/Sentry.flush()compiled toundefined: loaders and middleware that call them threwTypeError: (void 0) is not a function. Aworkerdkey now comes first and resolves the Cloudflare entry. Only Cloudflare setsworkerd, so nothing else changes: movingworkerabovebrowserwould also have switched webpack builds withtarget: 'webworker', which setworkerandbrowser, to the Cloudflare entry.On Cloudflare,
react-router buildprerenders pages by running them through the wrapped Worker, soinjectTraceMetaTagswrote a build-timesentry-traceandbaggageinto the static HTML. Every visitor of a prerendered page then continued that one trace with its sampling decision. Such a path never reaches the handler in production (it is served as a static file), so a render of a path from the build'sprerenderlist is the build-time prerender, and it now gets no meta tags. For that, the server build capture also recordsprerender, andwrapSentryHandleRequestregisters the capture: on Cloudflare only the Node server integration did that before, so the build was never captured there.An index route has no
pathof its own, sowrapSentryHandleRequestnever gave it a route name. On Node, Express names the span first and hid this. On runtimes without that layer (Bun, and a React Router app on any non-Express server) the index page kept a URL-sourced name, so its baggage had nosentry-transaction. An index route now takes its nearest ancestor's path, or/. On Node this changes the transaction of an index page from Express's catch-allGET *toGET /, which is whyreact-router-7-framework-staticnow expects that name.🤖 Generated with Claude Code