feat(react-router): Add Experimental React Server Components (RSC) instrumentation#18882
feat(react-router): Add Experimental React Server Components (RSC) instrumentation#18882onurtemizkan wants to merge 24 commits intodevelopfrom
Conversation
node-overhead report 🧳Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.
|
159fb80 to
07fc2d6
Compare
|
@onurtemizkan sorry this one went under the radar. Can you resolve the conflict and ping me again? |
07fc2d6 to
c94138a
Compare
|
@chargome, it's ready for review 👍 |
Codecov Results 📊Generated by Codecov Action |
chargome
left a comment
There was a problem hiding this comment.
Generally LGTM to me but is there a way we could already wrap the server components with vite? Also initing the Client in a hook might happen quite late – any ideas if the client will eventually support an entry file?
| /** | ||
| * WeakSet to track errors that have been captured to avoid double-capture. | ||
| * Uses WeakSet so errors are automatically removed when garbage collected. | ||
| */ | ||
| const CAPTURED_ERRORS = new WeakSet<object>(); |
There was a problem hiding this comment.
q: Why do we need this in here? We have a dedupe integration that should take of this I think?
packages/react-router/src/server/rsc/wrapMatchRSCServerRequest.ts
Outdated
Show resolved
Hide resolved
7954e55 to
141002a
Compare
e10f4e4 to
e082621
Compare
size-limit report 📦
|
| // - minor import and export changes | ||
| // - merged the two files linked above into one for simplicity | ||
|
|
||
| // Date of access: 2025-03-04 |
There was a problem hiding this comment.
Incorrect date in source attribution comment
Low Severity
The comment states "Date of access: 2025-03-04" but today's date is 2026-02-19. This appears to be placeholder text or an incorrect timestamp that was accidentally left in the code during development. The date should either be corrected to reflect when the code was actually accessed, or removed if it's not meaningful.
239bc9f to
7feed8e
Compare
59f2077 to
77e55c9
Compare
| /** | ||
| * Enable debug logging to see which files are being instrumented. | ||
| * @default false | ||
| */ | ||
| debug?: boolean; |
There was a problem hiding this comment.
Is there a specific reason, why there is another debug option? Would it be possible to use the one from the client options?
c0f9783 to
8f21d5c
Compare
| [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route', | ||
| 'rsc.server_function.name': functionName, | ||
| ...options.attributes, | ||
| }, |
There was a problem hiding this comment.
Custom attributes can overwrite internal Sentry span attributes
Low Severity
In wrapServerFunction, ...options.attributes is spread after the internal Sentry attributes (SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE), allowing user-provided attributes to silently overwrite them. This could break span categorization and origin tracking. The spread order could be reversed so Sentry-internal attributes take precedence.
Triggered by project rule: PR Review Guidelines for Cursor Bot
…lag in RSC wrappers
…instrumentation opt-in
267d969 to
98cd9d4
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.
| else score += STATIC_SEGMENT_SCORE; | ||
| } | ||
| return score; | ||
| } |
There was a problem hiding this comment.
Two iterations over segments array in computeScore
Low Severity
computeScore iterates segments twice: first with segments.includes('*') and then with the for...of loop. Since the * check within the loop already handles segment === '*' with continue, the splat penalty could be applied inside the same loop, consolidating both passes into one. This is on the request hot path in matchUrlToManifestRoute.
Triggered by project rule: PR Review Guidelines for Cursor Bot


Resolves: #17337
Adds experimental error capture and performance monitoring for React Router v7's React Server Components mode (v7.9.0+).
In RSC mode,
entry.server.tsxis bypassed for server component renders, so wrapSentryHandleRequest never runs. HTTP spans are not parameterized, transaction names are not set, and errors in server components and server functions are not captured.Server Components
Added
wrapServerComponent()for error capture and span parameterization:GET /users/:id)Server Functions
Added
wrapServerFunction()for"use server"functions:Each invocation creates a dedicated span with op
function.rsc.server_functionandforceTransaction: truewhen no parent span exists.Automatic Server Function Instrumentation
Added a Vite plugin that auto-wraps all exported functions in
"use server"files. Opt-in only:Uses AST parsing (recast + @babel/parser) to detect
"use server"directives and exported functions. Skips files that already importwrapServerFunction. Server components are not auto-instrumented.Also:
wrapSentryHandleRequestfor RSC mode wherestaticHandlerContext.matchesis not populatedwrapServerComponentandwrapServerFunctionto prevent import errors@babel/parserandrecastas dependencies for AST parsing (Similar to SvelteKit)