-
-
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
fix(v8/react): Improve handling of routes nested under path="/" #14897
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
We noticed this in Sentry's `/issues/:groupId/` route, which uses SDK v8.43.0. The full route tree is complex, but the relevant parts are: ```js <Route path="/" element={<div>root</div>}> <Route path="/issues/:groupId/" element={<div>issues group</div>}> <Route index element={<div>index</div>} /> </Route> </Route> ``` If you navigate to e.g. `/issues/123` (no trailing slash), the recorded transaction name is `//issues/:groupId/` (notice the double slash). This looks messy but doesn't have too much of a consequence. The worse issue is when you navigate to e.g. `/issues/123/` (with trailing slash), the transaction name is `/issues/123/` - it is not parameterized. This breaks transaction grouping. On the `master` and `develop` branch of the SDK, the transaction name is recorded as `/`. This causes the transactions to be grouped incorrectly with the root, as well as any other routes nested under a route with `path="/"`. (Thanks @JoshFerge for noticing the bad data in Sentry! 🙌) --- Note that this commit effectively reverts a change from #14304 where ```js if (basename + branch.pathname === location.pathname) { ``` became ```js if (location.pathname.endsWith(basename + branch.pathname)) { ``` This is the change that caused the difference in results between SDK versions. This will always match when `basename` is empty, `branch.pathname` is `/`, and `location.pathname` ends with `/` - in other words, if you have a parent route with `path="/"`, every request ending in a slash will match it instead of the more specific child route. (Depending on how often this kind of `Route` nesting happens in the wild, this could be a wide regression in transaction names.) But, no tests failed from the removal of `endsWith`. @onurtemizkan, who wrote the change in question: > I'd expect this to break descendant routes. But in the final > implementation, descendant routes don't end up here. So, I > believe it's safe to revert.
onurtemizkan
changed the title
fix(v8/react): improve handling of routes nested under path="/" (#14821)
fix(v8/react): Improve handling of routes nested under path="/"
Jan 3, 2025
chargome
approved these changes
Jan 3, 2025
alexandresoro
pushed a commit
to alexandresoro/ouca
that referenced
this pull request
Jan 7, 2025
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [@sentry/node](https://github.com/getsentry/sentry-javascript/tree/master/packages/node) ([source](https://github.com/getsentry/sentry-javascript)) | dependencies | minor | [`8.47.0` -> `8.48.0`](https://renovatebot.com/diffs/npm/@sentry%2fnode/8.47.0/8.48.0) | | [@sentry/react](https://github.com/getsentry/sentry-javascript/tree/master/packages/react) ([source](https://github.com/getsentry/sentry-javascript)) | dependencies | minor | [`8.47.0` -> `8.48.0`](https://renovatebot.com/diffs/npm/@sentry%2freact/8.47.0/8.48.0) | --- ### Release Notes <details> <summary>getsentry/sentry-javascript (@​sentry/node)</summary> ### [`v8.48.0`](https://github.com/getsentry/sentry-javascript/releases/tag/8.48.0) [Compare Source](getsentry/sentry-javascript@8.47.0...8.48.0) ##### Deprecations - **feat(v8/core): Deprecate `getDomElement` method ([#​14799](getsentry/sentry-javascript#14799 Deprecates `getDomElement`. There is no replacement. ##### Other changes - fix(nestjs/v8): Use correct main/module path in package.json ([#​14791](getsentry/sentry-javascript#14791)) - fix(v8/core): Use consistent `continueTrace` implementation in core ([#​14819](getsentry/sentry-javascript#14819)) - fix(v8/node): Correctly resolve debug IDs for ANR events with custom appRoot ([#​14823](getsentry/sentry-javascript#14823)) - fix(v8/node): Ensure `NODE_OPTIONS` is not passed to worker threads ([#​14825](getsentry/sentry-javascript#14825)) - fix(v8/angular): Fall back to element `tagName` when name is not provided to `TraceDirective` ([#​14828](getsentry/sentry-javascript#14828)) - fix(aws-lambda): Remove version suffix from lambda layer ([#​14843](getsentry/sentry-javascript#14843)) - fix(v8/node): Ensure express requests are properly handled ([#​14851](getsentry/sentry-javascript#14851)) - feat(v8/node): Add `openTelemetrySpanProcessors` option ([#​14853](getsentry/sentry-javascript#14853)) - fix(v8/react): Use `Set` as the `allRoutes` container. ([#​14878](getsentry/sentry-javascript#14878)) ([#​14884](getsentry/sentry-javascript#14884)) - fix(v8/react): Improve handling of routes nested under path="/" ([#​14897](getsentry/sentry-javascript#14897)) - feat(v8/core): Add `normalizedRequest` to `samplingContext` ([#​14903](getsentry/sentry-javascript#14903)) - fix(v8/feedback): Avoid lazy loading code for `syncFeedbackIntegration` ([#​14918](getsentry/sentry-javascript#14918)) Work in this release was contributed by [@​arturovt](https://github.com/arturovt). Thank you for your contribution! ##### Bundle size 📦 | Path | Size | | ---------------------------------------------------------------- | ----------------- | | [@​sentry/browser](https://github.com/sentry/browser) | 23.29 KB | | [@​sentry/browser](https://github.com/sentry/browser) - with treeshaking flags | 21.96 KB | | [@​sentry/browser](https://github.com/sentry/browser) (incl. Tracing) | 35.85 KB | | [@​sentry/browser](https://github.com/sentry/browser) (incl. Tracing, Replay) | 73.09 KB | | [@​sentry/browser](https://github.com/sentry/browser) (incl. Tracing, Replay) - with treeshaking flags | 63.48 KB | | [@​sentry/browser](https://github.com/sentry/browser) (incl. Tracing, Replay with Canvas) | 77.4 KB | | [@​sentry/browser](https://github.com/sentry/browser) (incl. Tracing, Replay, Feedback) | 89.34 KB | | [@​sentry/browser](https://github.com/sentry/browser) (incl. Feedback) | 39.5 KB | | [@​sentry/browser](https://github.com/sentry/browser) (incl. sendFeedback) | 27.89 KB | | [@​sentry/browser](https://github.com/sentry/browser) (incl. FeedbackAsync) | 32.69 KB | | [@​sentry/react](https://github.com/sentry/react) | 25.96 KB | | [@​sentry/react](https://github.com/sentry/react) (incl. Tracing) | 38.66 KB | | [@​sentry/vue](https://github.com/sentry/vue) | 27.56 KB | | [@​sentry/vue](https://github.com/sentry/vue) (incl. Tracing) | 37.69 KB | | [@​sentry/svelte](https://github.com/sentry/svelte) | 23.45 KB | | CDN Bundle | 24.49 KB | | CDN Bundle (incl. Tracing) | 37.56 KB | | CDN Bundle (incl. Tracing, Replay) | 72.75 KB | | CDN Bundle (incl. Tracing, Replay, Feedback) | 78.11 KB | | CDN Bundle - uncompressed | 71.93 KB | | CDN Bundle (incl. Tracing) - uncompressed | 111.42 KB | | CDN Bundle (incl. Tracing, Replay) - uncompressed | 225.5 KB | | CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed | 238.6 KB | | [@​sentry/nextjs](https://github.com/sentry/nextjs) (client) | 38.92 KB | | [@​sentry/sveltekit](https://github.com/sentry/sveltekit) (client) | 36.36 KB | | [@​sentry/node](https://github.com/sentry/node) | 162.8 KB | | [@​sentry/node](https://github.com/sentry/node) - without tracing | 98.94 KB | | [@​sentry/aws-serverless](https://github.com/sentry/aws-serverless) | 126.63 KB | </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS45Mi4wIiwidXBkYXRlZEluVmVyIjoiMzkuOTIuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiZGVwZW5kZW5jaWVzIl19--> Reviewed-on: https://git.tristess.app/alexandresoro/ouca/pulls/454 Reviewed-by: Alexandre Soro <[email protected]> Co-authored-by: renovate <[email protected]> Co-committed-by: renovate <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backports #14821