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
{{ message }}
Repository navigation
tanstackRouterBrowserTracingIntegration: pageload transaction name ignores router basepath #23253
tanstackRouterBrowserTracingIntegration names the pageload span by matching the raw window.location.pathname, which still contains the router basepath. router.matchRoutes(pathname) expects a router-relative pathname (TanStack applies the basepath as a URL rewrite in parseLocation, so latestLocation.pathname never contains it). With a non-/ basepath the pageload transaction is therefore matched against the wrong path.
The navigation / onResolved paths are correct — they use toLocation.pathname, which is already basepath-stripped. Only the initial pageload name is affected.
Code
packages/react/src/tanstackrouter.ts (still present in 10.70.0):
constinitialWindowLocation=WINDOW.location;if(instrumentPageLoad&&initialWindowLocation){constrouteMatch=resolveRouteMatch(initialWindowLocation.pathname,// <-- includes basepathcastRouterInstance.options.parseSearch(initialWindowLocation.search),);
...
}
constrouter=createRouter({basepath: "/app",
routeTree,// contains '/reports/$id' and a catch-all '/$a/$b/$c'});
Load /app/reports/123.
Expected pageload transaction: /reports/$id
Actual: /$a/$b/$c, with url.path.params.a = "app"
getMatchedRoutes matches fuzzily, so the extra basepath segments get absorbed by any sufficiently dynamic route and a plausible-but-wrong route id wins. When no route absorbs them you instead fall back to source: "url" with the raw pathname as the name.
This is not just cosmetic: the scope transaction is set when the pageload span starts, and the later span.updateName() in onResolved does not rewrite it — so error events keep the wrong transaction/culprit for the whole page lifetime, including errors thrown long after load.
Suggested fix
Strip router.basepath from initialWindowLocation.pathname before calling resolveRouteMatch (only when it is a real prefix followed by / or end of string).
Activity
linear-code commentedon Aug 11, 2026
JS-3341
JPeer264 commentedon Aug 11, 2026
Hey, thanks a lot for filing this issue and having a reproduction in it. I'll try to reproduce it and try to fix it
fix(react): Match TanStack Router pageload against the router location (
fix(react): Match TanStack Router pageload against the router location (