Skip to content

fix(core): Wrap SDK logic in try/catch in NavigationContainer onReady

134cc57
Select commit
Loading
Failed to load commit list.
Open

feat(tracing): Add Sentry.NavigationContainer wrapper for React Navigation #6199

fix(core): Wrap SDK logic in try/catch in NavigationContainer onReady
134cc57
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden: code-review completed May 21, 2026 in 4m 20s

2 issues

code-review: Found 2 issues (2 low)

Low

Module-level `_warned*` flags not reset between test cases cause flaky warning assertions

In NavigationContainer.tsx, _warnedNoClient and _warnedNoIntegration are module-level singletons. jest.clearAllMocks() in beforeEach resets mock call counts but not these flags, so if a test that triggers a warning runs before another test asserting on the same warning mock, the second assertion will fail. Consider resetting these flags via a test-only export or using jest.resetModules().

Module-level `_warned*` flags persist across tests, making warning assertions order-dependent - `packages/core/src/js/index.ts:117`

NavigationContainer.tsx declares three module-level booleans (_warnedMissing, _warnedNoClient, _warnedNoIntegration) that are set to true on first trigger and never reset. The test suite's beforeEach calls only jest.clearAllMocks(), which does not reset module state. Currently each warning branch is asserted in exactly one test, so the suite passes; however, if either of the two warning tests is duplicated, reordered, or a new test exercises the same branch, debug.warn/debug.log will not fire again and the assertion will silently fail. Consider adding jest.resetModules() (with dynamic re-import) or jest.isolateModules around the warning tests, or exposing a test-only reset helper to keep these assertions robust.

Also found at:

  • packages/core/test/NavigationContainer.test.tsx:56

โฑ 3m 38s ยท 294.2k in / 38.4k out ยท $1.18