Skip to content

fix(tracing): Retry expoRouterIntegration navigationRef lookup#6451

Merged
alwx merged 6 commits into
mainfrom
alwx/fix/6431
Jul 16, 2026
Merged

fix(tracing): Retry expoRouterIntegration navigationRef lookup#6451
alwx merged 6 commits into
mainfrom
alwx/fix/6431

Conversation

@alwx

@alwx alwx commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

📢 Type of change

  • Bugfix

📜 Description

expoRouterIntegration only checked store.navigationRef once synchronously in afterAllSetup. If it was still undefined (typical on cold start), the integration warned and bailed — even though the sibling navigationRef.current check already had polling.

Merged both checks into a single polling loop that waits for store.navigationRef to appear and then for .current to be populated, within the existing 5s window. Adding the underlying reactNavigationIntegration is deferred until the ref is actually seen, so a repo without expo-router (or an incompatible version) still ends up with no integration added — same as before.

💡 Motivation and Context

Fixes #6431. Sentry.init() runs at module eval time (as the docs recommend), which is before Expo Router's Root Layout mounts. That made registerNavigationContainer() reliably miss its window on cold start, so no per-navigation transactions were produced for the rest of the session.

💚 How did you test it?

  • New test picks up navigationRef when it appears mid-poll (issue #6431) — simulates the cold-start ordering (both fields undefined at setup, then appearing) and asserts the container gets registered.
  • Updated the existing "navigationRef missing" test to reflect the new behavior: warn only after the timeout.
  • All existing tests in expoRouterIntegration.test.ts still pass (11 total).

📝 Checklist

  • I added tests to verify changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • All tests passing.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.
  • No breaking changes.

🔮 Next steps

alwx added 2 commits July 15, 2026 13:24
Poll for both `store.navigationRef` and `navigationRef.current` to appear,
instead of bailing on the first synchronous check. `Sentry.init()` runs at
module eval time (as the docs recommend), which is before Expo Router's Root
Layout mounts and populates `store.navigationRef`.

Fixes #6431
@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Semver Impact of This PR

None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


  • fix(tracing): Retry expoRouterIntegration navigationRef lookup by alwx in #6451
  • feat(core): Aggregate TurboModule call counts and latency per (module, method, kind) by alwx in #6377
  • chore(deps): bump the codeql-action group with 2 updates by dependabot in #6461
  • fix(core): Fix stale route when reactNavigationIntegration uses a route override provider by alwx in #6458
  • chore(deps): update Android SDK to v8.49.0 by github-actions in #6459
  • feat(android): Add enableHistoricalTombstoneReporting option by Cryptoteep in #6450
  • docs(sdk-versions): Add 8.14.2 row to main by alwx in #6456
  • docs(changelog): Add 8.14.2 changelog entry by alwx in #6455
  • chore(deps): bump ruby/setup-ruby from 1.314.0 to 1.316.0 by dependabot in #6446
  • chore(deps): bump actions/setup-java from 5.3.0 to 5.5.0 by dependabot in #6444
  • chore(deps): bump github/codeql-action/analyze from 4.36.3 to 4.37.0 by dependabot in #6443
  • chore(deps): bump dorny/paths-filter from 4.0.1 to 4.0.2 by dependabot in #6442
  • chore(deps): update JavaScript SDK to v10.65.0 by github-actions in #6441
  • fix(ios): Break RNSentryOnDrawReporterView retain cycle in emit-new-frame block by alwx in #6449
  • refactor(ios): Migrate from PrivateSentrySDKOnly to SentrySDK.internal by alwx in #6380
  • docs: Improve PR template guidance by sentry-junior in #6447
  • fix(ios): Resolve getNewScreenTimeToDisplay Promise with number not array by antonis in #6438
  • fix(feedback): Guard show/hide against uninitialized _setVisibility by antonis in #6435
  • fix(tracing): Fix orphaned TTID/TTFD spans in the trace view by antonis in #6437
  • feat(tracing): Add reportFullyDisplayed() static API by antonis in #6419
  • feat(core): Track CaptureAppStartErrors adoption by antonis in #6429
  • feat(replay): Track mobile replay network capture adoption by antonis in #6428
  • feat(tracing): Track standalone app start adoption by antonis in #6427
  • feat(tracing): Track appLoaded and extendAppStart adoption by antonis in #6426

Plus 3 more


🤖 This preview updates automatically when you update the PR.

@alwx alwx marked this pull request as ready for review July 15, 2026 11:56
@alwx alwx self-assigned this Jul 15, 2026
@alwx

alwx commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 6986cf4. Configure here.

Comment thread packages/core/src/js/tracing/expoRouterIntegration.ts
alwx and others added 2 commits July 16, 2026 09:25
…is possible

Only attach `reactNavigationIntegration` when `navigationRef.current` is
ready to register, so a poll timeout can never leave a non-functional
integration on the client.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

@lucas-zimerman lucas-zimerman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solid! LGTM one ci test pass

@alwx alwx added the ready-to-merge Triggers the full CI test suite label Jul 16, 2026
@sentry

sentry Bot commented Jul 16, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
Sentry RN io.sentry.reactnative.sample 8.18.0 (98) Release

⚙️ sentry-react-native Build Distribution Settings

@github-actions

Copy link
Copy Markdown
Contributor

Android (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 484.33 ms 567.18 ms 82.85 ms
Size 49.74 MiB 55.33 MiB 5.58 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
f3215d3+dirty 411.11 ms 454.38 ms 43.27 ms
d2eadf8+dirty 414.64 ms 454.56 ms 39.92 ms
b0d3373+dirty 557.66 ms 579.42 ms 21.76 ms
27d9693+dirty 419.08 ms 469.12 ms 50.04 ms
4e0b819+dirty 420.56 ms 470.08 ms 49.52 ms
9474ead+dirty 411.45 ms 446.80 ms 35.35 ms
0bd8916+dirty 412.77 ms 451.31 ms 38.54 ms
f9c1ed4+dirty 431.00 ms 466.22 ms 35.22 ms
3d536d1+dirty 524.34 ms 547.32 ms 22.98 ms
04207c4+dirty 459.19 ms 518.54 ms 59.35 ms

App size

Revision Plain With Sentry Diff
f3215d3+dirty 48.30 MiB 53.49 MiB 5.19 MiB
d2eadf8+dirty 48.30 MiB 53.48 MiB 5.18 MiB
b0d3373+dirty 48.30 MiB 53.58 MiB 5.28 MiB
27d9693+dirty 49.74 MiB 55.09 MiB 5.34 MiB
4e0b819+dirty 49.74 MiB 54.81 MiB 5.07 MiB
9474ead+dirty 48.30 MiB 53.61 MiB 5.30 MiB
0bd8916+dirty 48.30 MiB 53.57 MiB 5.26 MiB
f9c1ed4+dirty 49.74 MiB 54.86 MiB 5.12 MiB
3d536d1+dirty 49.74 MiB 55.26 MiB 5.52 MiB
04207c4+dirty 43.75 MiB 48.12 MiB 4.37 MiB

@alwx alwx merged commit 4b5b5d8 into main Jul 16, 2026
84 of 93 checks passed
@alwx alwx deleted the alwx/fix/6431 branch July 16, 2026 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Triggers the full CI test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

expoRouterIntegration's store.navigationRef check has no retry, fails on every cold start when Sentry.init() runs before React renders

2 participants