Skip to content

test(react-router): Use a separate URL per loader error test in instrumentation API e2e test - #25607

Open
mydea wants to merge 2 commits into
developfrom
test/react-router-error-trace-flake
Open

mydea wants to merge 2 commits into
developfrom
test/react-router-error-trace-flake

Conversation

@mydea

@mydea mydea commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

error and segment span should share the same trace is flaky in the dev-mode run of react-router-7-framework-instrumentation. On recent develop runs it fails on the first attempt and passes on retry, and on #25602 it failed every retry.

Root cause: errors are sent right away but streamed spans are buffered and flushed later. The three tests before this one all hit /performance/error-loader, so the segment span listener picks up a late span from an earlier request. In every failed attempt, the error's trace id matches the span the next attempt receives.

Rather than working around this in the assertion, the route is now /performance/error-loader/:id and each loader test requests its own id. The loader puts the id into the error message, and tests match the segment span by url.full, so a late error or span from another test can no longer match.

🤖 Generated with Claude Code

…ntation API e2e test

Streamed spans flush after errors, so the segment span listener could pick up a late span from an
earlier test that hit the same route, making the trace id assertion flaky (mostly in dev mode).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Compared: c31a5d1 (PR test merge using develop at a6c28d0)

Against: a6c28d0 (develop) · base run #63870

✅ Baseline matches: this diff contains only this PR's changes.

Path Size % Change Change
@sentry/browser 30.33 kB - -
@sentry/browser - with treeshaking flags 28.45 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 28.34 kB - -
@sentry/browser (incl. Tracing) 52.54 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 52.54 kB - -
@sentry/browser (incl. Tracing, Profiling) 55.47 kB - -
@sentry/browser (incl. Tracing, Replay) 92.3 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 81.18 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 97.04 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 110.03 kB - -
@sentry/browser (incl. Feedback) 47.89 kB - -
@sentry/browser (incl. sendFeedback) 35.4 kB - -
@sentry/browser (incl. FeedbackAsync) 40.51 kB - -
@sentry/browser (incl. Metrics) 31.34 kB - -
@sentry/browser (incl. Logs) 31.62 kB - -
@sentry/browser (incl. Metrics & Logs) 32.3 kB - -
@sentry/react 32.14 kB - -
@sentry/react (incl. Tracing) 54.82 kB - -
@sentry/vue 38.46 kB - -
@sentry/vue (incl. Tracing) 55.45 kB - -
@sentry/svelte 30.36 kB - -
@sentry/remix (Remix 3 client bundle) 57.59 kB - -
CDN Bundle 32.06 kB - -
CDN Bundle (incl. Tracing) 53.02 kB - -
CDN Bundle (incl. Logs, Metrics) 34.26 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 54.99 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 75.25 kB - -
CDN Bundle (incl. Tracing, Replay) 90.74 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 92.67 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 96.85 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 98.82 kB - -
CDN Bundle - uncompressed 94.29 kB - -
CDN Bundle (incl. Tracing) - uncompressed 157.14 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 100.84 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 163.11 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 231.06 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 277.48 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 283.44 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 291.18 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 297.13 kB - -
@sentry/nextjs (client) 57.69 kB - -
@sentry/sveltekit (client) 53 kB - -
@sentry/core/server 43.69 kB - -
@sentry/core/browser 13.81 kB - -
@sentry/node 154.24 kB +0.01% +15 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 81.62 kB - -
@sentry/node - without tracing 95.55 kB +0.02% +17 B 🔺
@sentry/node - without channel injection 134.9 kB +0.01% +3 B 🔺
@sentry/aws-serverless 103.71 kB +0.01% +7 B 🔺
@sentry/cloudflare (withSentry) - minified 197.28 kB - -
@sentry/cloudflare (withSentry) 490.08 kB - -
@sentry/nextjs/cloudflare (withSentry) - minified 217.86 kB - -

View base workflow run

@mydea
mydea marked this pull request as ready for review October 21, 2026 11:37
@mydea
mydea requested review from a team, chargome and s1gr1d and removed request for a team October 21, 2026 11:37

@s1gr1d s1gr1d left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this would fix the flake, we could still solve this at the "root" by just not hitting the same endpoint in every test. Maybe we can add a parametrized route (e.g. /error-loader/:test-id) or something.

@mydea

mydea commented Oct 28, 2026

Copy link
Copy Markdown
Member Author

While this would fix the flake, we could still solve this at the "root" by just not hitting the same endpoint in every test. Maybe we can add a parametrized route (e.g. /error-loader/:test-id) or something.

yeah this is a good point, maybe worth it to rewrite this 👍

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mydea mydea changed the title test(react-router): Match error and segment span by trace in instrumentation API e2e test test(react-router): Use a separate URL per loader error test in instrumentation API e2e test Oct 28, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 4ecb93d. Configure here.

function isErrorLoaderSegment(span: SerializedStreamedSpan, id: string): boolean {
const url = span.attributes['url.full']?.value;
return span.is_segment && typeof url === 'string' && url.endsWith(`/performance/error-loader/${id}`);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Span matcher collides with client pageload

Medium Severity

isErrorLoaderSegment accepts any segment whose url.full ends with the test path. A client pageload segment for that same URL also matches, and streamed server spans flush later, so waitForStreamedSpan can resolve the client span. The mechanism test then fails its http.server / GET ... checks. This is flagged because the testing conventions require wait predicates to be unique when telemetry can arrive in any order.

Additional Locations (2)
Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

Reviewed by Cursor Bugbot for commit 4ecb93d. Configure here.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants