Closed
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/react
SDK Version
8.0.0
Framework Version
18.3.1
Link to Sentry event
No response
SDK Setup
Sentry.init({
dsn: '***',
integrations: [
Sentry.reactRouterV6BrowserTracingIntegration({
useEffect,
useLocation,
useNavigationType,
createRoutesFromChildren,
matchRoutes,
}),
Sentry.replayIntegration(),
],
tracesSampleRate: 0.1,
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
});Steps to Reproduce
I setup my react-router v6 as follows.
export function App() {
return (
<RouterProvider
router={Sentry.wrapCreateBrowserRouter(createBrowserRouter)([
{
path: '*',
element: <RouterEntry />,
children: [
/* my routes */
],
},
])}
/>
);
}Expected Result
Should load my routes 🎉
Actual Result
No routes load, and I see the following console error. I cannot find in the migration guide any changes about this so I assume it is a bug as on v7 this code works. Removing Sentry.wrapCreateBrowserRouter allows the routes to load again.
Uncaught (in promise) TypeError: _matchRoutes is not a function
at handleNavigation (@sentry_react.js?v=aff74ec4:29421:55)
at @sentry_react.js?v=aff74ec4:29508:9
at react-router-dom.js?v=aff74ec4:1257:46
at Array.forEach (<anonymous>)
at updateState (react-router-dom.js?v=aff74ec4:1257:22)
at completeNavigation (react-router-dom.js?v=aff74ec4:1332:5)
at startNavigation (react-router-dom.js?v=aff74ec4:1507:5)
Reacted by Tim Jünemann
Metadata
Metadata
Assignees
Labels
No labels
Projects
- StatusShow more project fieldsWaiting for: Product Owner
Activity
lforst commentedon May 14, 2024
Hi, thanks for writing in. I have two questions:
Sentry.init()is the first thing happening in your application?Slessi commentedon May 14, 2024
@lforst Yea, I am sure I called
Initfirst and don't have multiple sentry versions.https://stackblitz.com/edit/vitejs-vite-uhrib2?file=src%2Fmain.tsx
Struggled a bit recreating the repro. It seems to only happen when using
lazyto load elements. If you see in the above repro, the page does not load my "hi" component. Not sure how to open console inside stackblitz but if you open it as a new page, you will see:Replacing that
lazyprop withelement: <LazyComponent />(so a regular non-lazy import) fixes it also. But of course, I want to uselazy.lforst commentedon May 14, 2024
@Slessi ok it looks like this issue happens if no dsn is set because the react router integration doesn't run. Also, in your app
Sentry.init()was not the first thing being called. Note that imports are evaluated first.I opened a pr to degrade gracefully if the the integration doesn't run.
Slessi commentedon May 14, 2024
@lforst I put a DSN and changed imports so Sentry is the first import.
https://stackblitz.com/edit/vitejs-vite-uhrib2?file=src%2Fmain.tsx
I get the same problem when I add
enabled: falseor conditionally callSentry.init(which I did with V7). I do this to not send events from my local environment.Sharing just incase it is not solved by your PR.
14 remaining items
lforst commentedon May 14, 2024
@Slessi you are absolutely not coming off as a pest :D We have a bug and we'll fix it in a release tomorrow!
lleifermann commentedon May 16, 2024
@lforst Any update folks? The bug is stopping me right now from integrating Sentry 😢
Lms24 commentedon May 16, 2024
Hi @lleifermann we just released 8.1.0 which should prevent the error from happening and should make loading routes work again. Not sure though specifically why the functions aren't available in the first place (also missing context on this issue but jumping in for @lforst)
Considering this issue is about browser-only
@sentry/react, the import order shouldn't matter that much. Although we still recommend to init the SDK as soon a possible.lleifermann commentedon May 16, 2024
@Lms24 Just upgraded and it fixed my issue! Thanks alot for the quick timing on this! ❤️