-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
React Router browser tracing - Lazy imported routes with suspense start transaction spans with wrong path #15027
Comments
Hello, thanks for writing in and already trying to investigate this! We'll take a look at this. However, if you are interested in contributing, feel free to let me know and open a PR! :) Just for clarification: the first link to the code you posted is probably not the reason, as this is not the function which is used when setting up the routes with JSX. This would be this function:
|
Thanks for the issue report @peteragarclover! #15039 will add support for lazy-loaded components/pages on navigations. However, adding support for lazy-loaded routes is a bit more tricky, as we are currently unable to access the lazy-loaded sub-Routes, without breaking lazy-loading. I opened an issue to discuss how we can implement that - #15040 |
Thank you so much for the prompt update on this team 😍. Keen to try it out. Can I ask what release to expect this in? Will there be a minor, or should I wait for 9? Also, I didn't spot any documentation updates in the PR, but am I right in that the only change I will need to make, is for each const SentryRoutes = Sentry.withSentryReactRouterV6Routing(Routes); Lines 5 to 10 in 2e708dc
|
Actually, I'm a little confused by the test examples. sentry-javascript/dev-packages/e2e-tests/test-applications/react-create-browser-router/src/index.tsx Line 45 in 2e708dc
So, does the Ideally for us, it would just be |
@peteragarclover, that's just a deeper test case, making sure we're not losing the context in nested descendant lazy-routes. It should work out of the box for your case, without any configuration updates. Please let us know if you bump into any further issues. |
Is there an existing issue for this?
How do you use Sentry?
Self-hosted/on-premise
Which SDK are you using?
@sentry/react
SDK Version
8.47.0
Framework Version
React 18.3.1
Link to Sentry event
No response
Reproduction Example/SDK Setup
Init sentry with React Router browser tracing integration.
Configure React Router with Sentry wrapper. But Lazy import routes, e.g. something like:
Steps to Reproduce
"/"
(This initializes Sentry's route change subscriptions using routes available on initial page load)"/profile"
Expected Result
Navigation transaction span started using path
"/profile"
Actual Result
Navigation transaction span started using path
"/*"
This appears to be because the routes are only extracted once on mount:
sentry-javascript/packages/react/src/reactrouterv6-compat-utils.tsx
Lines 602 to 631 in 9f74bc9
And even though additional routes are lazy loaded, and the route name is correctly passed from the navigation event, when the name is normalized, it can't find the route, so falls back to the parent catch-all
"/*"
sentry-javascript/packages/react/src/reactrouterv6-compat-utils.tsx
Lines 333 to 342 in 9f74bc9
The text was updated successfully, but these errors were encountered: