feat(tracing): Correlate deep links with the navigation they trigger#6264
1 issue
code-review: Found 2 issues (1 medium, 1 low)
Medium
handleLateDeepLink can tag a previous navigation's idle span on warm open, leaving the actual triggered span untagged - `packages/core/etc/sentry-react-native.api.md:860`
In reactnavigation.ts handleLateDeepLink (line 250), when a warm-open deep link arrives while a previous navigation's idle span is still recording (lastIdleNavSpan not yet ended), the listener tags that unrelated span and returns true, preventing the link from being stored in the pending slot — so the navigation span actually triggered by the deep link never receives the navigation.trigger/deeplink.url attributes. Consider adding a staleness guard (e.g. comparing link.receivedAtMs against the span's start timestamp) before tagging via the listener path.
Low
`client.on('close')` unconditionally clears the module-level deep-link listener without an identity check - `packages/core/src/js/tracing/reactnavigation.ts:286-288`
In reactNavigationIntegration.afterAllSetup, the close handler calls setPendingDeepLinkListener(undefined) without verifying that the currently-registered listener is the one this client installed. pendingDeepLink.ts stores only a single module-level listener. If Sentry.init() is called a second time in the same JS runtime, the new client's afterAllSetup overwrites the listener with its own handleLateDeepLink closure; when the old client is later explicitly closed, its close handler clears whatever is registered — including the new client's listener — so late-arriving deep links stop being attributed to navigation spans for the rest of the session. An identity guard (e.g. only clear if the current listener is this closure) would prevent the cross-client clear.
⏱ 17m 49s · 1.7M in / 94.4k out · $3.14
Annotations
Check warning on line 860 in packages/core/etc/sentry-react-native.api.md
sentry-warden / warden: code-review
handleLateDeepLink can tag a previous navigation's idle span on warm open, leaving the actual triggered span untagged
In `reactnavigation.ts` `handleLateDeepLink` (line 250), when a warm-open deep link arrives while a previous navigation's idle span is still recording (`lastIdleNavSpan` not yet ended), the listener tags that unrelated span and returns `true`, preventing the link from being stored in the pending slot — so the navigation span actually triggered by the deep link never receives the `navigation.trigger`/`deeplink.url` attributes. Consider adding a staleness guard (e.g. comparing `link.receivedAtMs` against the span's start timestamp) before tagging via the listener path.