Skip to content

Maximum call stack size exceeded for nested routes (potential regression) #15279

Description

@dawsonbooth

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/react

SDK Version

8.45.0 and greater

Framework Version

18.3.1

Link to Sentry event

No response

Reproduction Example/SDK Setup

EDIT: https://stackblitz.com/edit/github-7tjxzc-f7d7tmwl?file=src%2Fmain.tsx

I'll work on getting an example up, but may take some time. Here's how I'm setting up Sentry – this all worked fine before upgrading the SDK:

if(import.meta.env.VITE_BUILD_ENV!=='local'){Sentry.init({environment: import.meta.env.VITE_BUILD_ENV,
dsn,integrations: [// https://docs.sentry.io/platforms/javascript/guides/react/configuration/integrations/react-router/Sentry.reactRouterV7BrowserTracingIntegration({
useEffect,
useLocation,
useNavigationType,
createRoutesFromChildren,
matchRoutes,}),Sentry.replayIntegration(),],replaysSessionSampleRate: 0.1,replaysOnErrorSampleRate: 1.0,release: import.meta.env.VITE_COMMIT_HASH,})}
constROUTES: RouteObject[]=[{path: '/',element: <Navigateto="/sample"/>},{path: 'sample/*',element: <SamplePages/>,},{path: 'login',element: <LoginPage/>,},{path: 'logout',element: <LogoutPage/>,},{path: '*',element: <NotFoundPage/>,},]constRouter: React.FC=()=>useRoutes(ROUTES)
constROUTER=createSentryBrowserRouter([{element: <Outlet/>,children: [{path: '/*',element: <Router/>}],
errorElement: <Fallbackerror/>,},])
<RouterProviderrouter={ROUTER}/>

Steps to Reproduce

  1. Run app
  2. Click on a link to navigate
  3. Observe that navigation did not occur and there is a console error message: "Maximum call stack size exceeded [...]"

Expected Result

Navigation works without error

Actual Result

URL updates but navigation does not occur. Error in console:

Uncaught (in promise) RangeError: Maximum call stack size exceeded
at String.replace (<anonymous>)
at chunk-IR6S3I6Y.mjs:637:93
at Array.reduce (<anonymous>)
at matchPath (chunk-IR6S3I6Y.mjs:633:31)
at matchRouteBranch (chunk-IR6S3I6Y.mjs:557:17)
at matchRoutesImpl (chunk-IR6S3I6Y.mjs:418:15)
at matchRoutes (chunk-IR6S3I6Y.mjs:405:10)
at rebuildRoutePathFromAllRoutes (reactrouterv6-compat-utils.tsx:394:93)
at rebuildRoutePathFromAllRoutes (reactrouterv6-compat-utils.tsx:408:93)
at rebuildRoutePathFromAllRoutes (reactrouterv6-compat-utils.tsx:408:93)
at rebuildRoutePathFromAllRoutes (reactrouterv6-compat-utils.tsx:408:93)
at rebuildRoutePathFromAllRoutes (reactrouterv6-compat-utils.tsx:408:93)

Metadata

Metadata

Assignees

Labels

Projects

Status
No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions