Skip to content

fix(react-router): Correct url attributes for history and relative navigations - #22131

Merged
Lms24 merged 4 commits into
developfrom
fix/react-router-navigation-url-resolution
Jul 10, 2026
Merged

fix(react-router): Correct url attributes for history and relative navigations#22131
Lms24 merged 4 commits into
developfrom
fix/react-router-navigation-url-resolution

Conversation

@Lms24

@Lms24Lms24 commented Jul 9, 2026

Copy link
Copy Markdown
Member

Follow-up to the merged url.* attribute work (#22018): That PR set url.template, url.path, and url.full on pageload/navigation spans, but exposed incorrect destination URLs for navigate(-1)/navigate(1) and relative navigate() targets. Similarly, independent of #22018, span names of relative navigations were also incorrect.

This PR fixes destination URL updates and span anmes after numeric navigation (legacy + instrumentation API), route parameterization for relative navigations via url.path matching, and adds E2E coverage for history back navigation.

@github-actions

github-actionsBot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize% ChangeChange
@sentry/browser27.6 kB--
@sentry/browser - with treeshaking flags26.04 kB--
@sentry/browser (incl. Tracing)46.35 kB--
@sentry/browser (incl. Tracing + Span Streaming)48.14 kB--
@sentry/browser (incl. Tracing, Profiling)51.13 kB--
@sentry/browser (incl. Tracing, Replay)85.62 kB--
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags75.26 kB--
@sentry/browser (incl. Tracing, Replay with Canvas)90.33 kB--
@sentry/browser (incl. Tracing, Replay, Feedback)102.99 kB--
@sentry/browser (incl. Feedback)44.78 kB--
@sentry/browser (incl. sendFeedback)32.4 kB--
@sentry/browser (incl. FeedbackAsync)37.53 kB--
@sentry/browser (incl. Metrics)28.68 kB--
@sentry/browser (incl. Logs)28.93 kB--
@sentry/browser (incl. Metrics & Logs)29.61 kB--
@sentry/react29.39 kB--
@sentry/react (incl. Tracing)48.62 kB--
@sentry/vue33.03 kB--
@sentry/vue (incl. Tracing)48.33 kB--
@sentry/svelte27.63 kB--
CDN Bundle30 kB--
CDN Bundle (incl. Tracing)48.33 kB--
CDN Bundle (incl. Logs, Metrics)31.58 kB--
CDN Bundle (incl. Tracing, Logs, Metrics)49.65 kB--
CDN Bundle (incl. Replay, Logs, Metrics)70.82 kB--
CDN Bundle (incl. Tracing, Replay)85.84 kB--
CDN Bundle (incl. Tracing, Replay, Logs, Metrics)87.16 kB--
CDN Bundle (incl. Tracing, Replay, Feedback)91.64 kB--
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics)92.92 kB--
CDN Bundle - uncompressed89.33 kB--
CDN Bundle (incl. Tracing) - uncompressed146.07 kB--
CDN Bundle (incl. Logs, Metrics) - uncompressed94.03 kB--
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed150.05 kB--
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed218.76 kB--
CDN Bundle (incl. Tracing, Replay) - uncompressed265.28 kB--
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed269.24 kB--
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed278.98 kB--
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed282.93 kB--
@sentry/nextjs (client)51.17 kB--
@sentry/sveltekit (client)46.8 kB--
@sentry/core/server78.42 kB--
@sentry/core/browser64.77 kB--
@sentry/node-core62.73 kB--
@sentry/node125.35 kB--
@sentry/node (incl. diagnostics channel injection)139.63 kB-0.01%-1 B 🔽
@sentry/node/import (ESM hook with diagnostics-channel injection)69.95 kB--
@sentry/node/light50.73 kB-0.01%-1 B 🔽
@sentry/node - without tracing74.04 kB-0.01%-1 B 🔽
@sentry/aws-serverless83.26 kB+0.01%+1 B 🔺
@sentry/cloudflare (withSentry) - minified181.47 kB--
@sentry/cloudflare (withSentry)448.98 kB--

View base workflow run

…vigations
The url.* attribute work surfaced incorrect destination URLs for
navigate(-1), navigate(1), and relative navigate() targets. Update
url.path/url.full after numeric navigation completes and match route
parameterization against url.path for relative navigations.
Co-Authored-By: Cursor <cursoragent@cursor.com>
@Lms24
Lms24force-pushed the fix/react-router-navigation-url-resolution branch from 73ea032 to 5cdb540CompareJuly 9, 2026 14:02
Move shared normalizePathname/getParameterizedRoute helpers to utils.ts and
add finalizeNavigationSpanFromHydratedRouter so createClientInstrumentation
does not need react-router types. Add tests for stale router state during
sync numeric navigation.
Co-Authored-By: Cursor <cursoragent@cursor.com>
@Lms24
Lms24 marked this pull request as ready for review July 9, 2026 17:00
@Lms24
Lms24 requested a review from a team as a code ownerJuly 9, 2026 17:00
@Lms24
Lms24 requested review from chargome, mydea and nicohrubec and removed request for a teamJuly 9, 2026 17:00
@Lms24Lms24 self-assigned this Jul 9, 2026

@chargomechargome 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.

Thanks for fixing these!

};

if (result != null && typeof (result as Promise<unknown>).then === 'function') {
void (result as Promise<unknown>).then(finalizeNumericNavigation);

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.

m: Would also finalize the navigation in the error case here (which is just an edge case if the navigation rejects)? In either case I'd appreciate a comment at this part to better understand whats going on 🙏

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

fixed. Also simplified the code and used isThenable instead of this ... check. Clankers gonna clank


const GLOBAL_OBJ_WITH_DATA_ROUTER = GLOBAL_OBJ as typeof GLOBAL_OBJ & {
__reactRouterDataRouter?: { state: RouterState };
};

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.

l: The type differs from the one declared in hydratedRouter:

constGLOBAL_OBJ_WITH_DATA_ROUTER=GLOBAL_OBJastypeofGLOBAL_OBJ&{__reactRouterDataRouter?: DataRouter;};

@Lms24
Lms24 merged commit d487dd9 into developJul 10, 2026
306 checks passed
@Lms24
Lms24 deleted the fix/react-router-navigation-url-resolution branch July 10, 2026 13:28
Sign up for freeto 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

@Lms24@chargome