You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Two independent router trees are each wrapped with Sentry's React Router
instrumentation (e.g. via withSentryReactRouterV6Routing / wrapCreateBrowserRouter), mounted at different points in the app's
lifecycle, For example, one router for /foo/:fooId and a separate,
unrelated router for /bar/:barId.
customer provided a full repro app. Link to that repo is included in internal Linear Issue to protect PII
Steps to Reproduce
Mount/navigate within Router A at /foo/123: transaction is correctly
named /foo/:fooId.
Mount/navigate within Router B at /bar/456.
Observe the transaction name for the /bar/456 navigation.
Expected Result
Transaction name: /bar/:barId
Actual Result
Transaction name is a hybrid/incorrect name such as /bar/:fooId
i.e. the static segment from Router B's path combined with the param
name from Router A's route.
Additional Context
Root cause (if I had to guess)
reactrouterv6-compat-utils.tsx accumulates every route object it has
ever seen into a module-level allRoutes Set, populated via getChildRoutesRecursively on each wrapped <Routes>'s mount effect,
and never scoped to a router instance or cleared on unmount:
This was introduced to support descendant routes / multiple <Routes>
trees that are legitimately part of the same logical route tree (see #14304). But because allRoutes has no isolation between genuinely
independent router instances, once two unrelated routers have each been
mounted once, matchRoutes/rebuildRoutePathFromAllRoutes operates on
the union of both, and can produce a name that mixes structure from one
router with param names from another.
Priority
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.
Taking a look at this, it is not a trivial fix because the global module-level set was added to fix #14304 and each <Routes> descendant is only aware of its own route fragment.
I think I can attempt reconstructing the full path and add that to the set instead for matching, will explore a couple of ideas.
Activity
linear-code commentedon Jul 28, 2026
JS-3213
vansh2408 commentedon Jul 28, 2026
/assign
logaretm commentedon Jul 28, 2026
Taking a look at this, it is not a trivial fix because the global module-level set was added to fix #14304 and each
<Routes>descendant is only aware of its own route fragment.I think I can attempt reconstructing the full path and add that to the set instead for matching, will explore a couple of ideas.
test(react): Add e2e repro for allRoutes accumulation across independ…
fix(react): Remove routes from shared set on `<Routes>` unmount
fix(react): Remove routes from shared set on `<Routes>` unmount (#22792)