Skip to content

fix(core): Stop wrapping RNSentry in TurboModuleContext by default - #6921

Merged
alwx merged 3 commits into
mainfrom
alwx/bugfix/6886
Oct 21, 2026
Merged

alwx merged 3 commits into
mainfrom
alwx/bugfix/6886

Conversation

@alwx

@alwx alwx commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

📢 Type of change

  • Bugfix

📜 Description

turboModuleContextIntegration no longer wraps the SDK's own RNSentry module by default. To wrap it again, add { name: 'RNSentry' } to the modules option. The integration then merges the scope-sync skip list in itself, so it cannot recurse. User-supplied modules are still wrapped for crash context.

💡 Motivation and Context

Each wrapped RNSentry call wrote the turbo_module context and two tags to the scope at start and end. Scope sync forwards every write to the native SDK, and sentry-cocoa saves each scope change to disk. This added about 5 ms of CPU to every SDK call on iOS. Since RNSentry was already ignored for aggregate stats, the wrap only produced a crash tag naming the SDK method in flight.

Fixes #6886

💚 How did you test it?

Added two Jest tests: RNSentry is not wrapped by default, and an RNSentry call makes no scope writes. Both failed before the fix. yarn test, yarn lint, yarn circularDepCheck, and yarn api-report:check pass.

📝 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.

alwx added 2 commits October 21, 2026 10:46
Each wrapped RNSentry call wrote the turbo_module context and two tags to
the isolation scope at start and end. Scope sync forwards every write to
the native SDK, and sentry-cocoa persists each scope change to disk for
watchdog termination tracking. The SDK calls RNSentry about 54 times per
tab switch, so this added about 5 ms of CPU per call on iOS.

RNSentry is already in the default ignoreTurboModules list, so with
default options the wrap only produced crash context for the SDK's own
calls. Now RNSentry is wrapped only when the user removes it from
ignoreTurboModules, which keeps the opt-in aggregate behavior.

Fixes #6886
@github-actions

github-actions Bot commented Oct 21, 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(core): Stop wrapping RNSentry in TurboModuleContext by default by alwx in #6921
  • chore(deps): bump launch-editor from 2.14.1 to 2.14.2 by dependabot in #6922
  • ci: Fix Linux jobs on Ubuntu 26.04 runners by antonis in #6920
  • fix(core): Match Sentry package paths with Windows separators in Metro resolvers by alwx in #6915
  • chore(e2e): Update Expo sample to SDK 58 by antonis in #6914
  • chore(e2e): Bump E2E tests to React Native 0.88.0 by antonis in #6899
  • fix(ios): Find .xcode.env in the debug symbols phase under SwiftPM by alwx in #6911
  • chore(deps): update React Native to v0.88.0 by github-actions in #6903
  • chore(deps): bump getsentry/craft from 2.34.1 to 2.35.0 by dependabot in #6906
  • chore(deps): bump actions/create-github-app-token from 3.2.0 to 3.3.0 by dependabot in #6908
  • chore(deps): bump getsentry/craft/.github/workflows/changelog-preview.yml from 2.33.1 to 2.35.0 by dependabot in #6907
  • chore(sample): Bump React Native sample to 0.88.0 by antonis in #6910
  • chore(deps): bump actions/setup-java from 6.0.1 to 6.1.0 by dependabot in #6909
  • chore(deps): bump the codeql-action group with 3 updates by dependabot in #6905
  • chore(deps): update Sentry Android Gradle Plugin to v6.24.0 by github-actions in #6902
  • chore(deps): bump @appium/support from 7.0.6 to 7.2.8 by dependabot in #6897
  • ci(e2e): Remove app metrics job and performance-tests by antonis in #6896

🤖 This preview updates automatically when you update the PR.

@alwx
alwx marked this pull request as ready for review October 21, 2026 09:35

@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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 5c645a6. Configure here.

Comment thread packages/core/src/js/integrations/turboModuleContext.ts Outdated

@antonis antonis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @alwx 🙇 Turning off the RNSentry wrap by default fixes the reported cost.

The Cursor finding looks valid. Also wdyt of opting in through modules only, not through ignoreTurboModules. With the current approach anyone who sets their own ignore list turns the wrap back on without knowing it.

Review feedback on #6921. Two problems with gating the wrap on
ignoreTurboModules:

- Any user who sets a custom ignore list without RNSentry would turn the
  wrap back on without knowing it.
- Passing RNSentry through modules wrapped it without RNSENTRY_SKIP, so
  the first SDK call recursed through scope sync until the app crashed.

RNSentry is now wrapped only when it is listed in modules. For that entry
the integration resolves the module itself when none is given and always
merges RNSENTRY_SKIP into the skip list. The module field becomes optional
so that { name: 'RNSentry' } is enough.
@alwx
alwx requested a review from a team as a code owner October 21, 2026 11:58
@alwx

alwx commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks, both points were valid and both are fixed now.

  • RNSentry is now wrapped only when it is listed in modules. ignoreTurboModules no longer controls the wrap, so a custom ignore list cannot turn it on by accident.
  • RNSentry entry in modules always gets RNSENTRY_SKIP merged into its skip list and the SDK resolves the module itself when module is not given so { name: 'RNSentry' } is enough. This removes the recursion Bugbot found.

The module field in modules became optional. The API report is updated.

@antonis antonis added the ready-to-merge Triggers the full CI test suite label Oct 21, 2026

@antonis antonis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM after the tests go 🟢

@sentry

sentry Bot commented Oct 21, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

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

⚙️ sentry-react-native Build Distribution Settings

@alwx
alwx merged commit 3fa163e into main Oct 21, 2026
121 of 127 checks passed
@alwx
alwx deleted the alwx/bugfix/6886 branch October 21, 2026 15:20
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.

TurboModuleContext (default since 8.14) adds ~5 ms of CPU to every RNSentry call on iOS through native scope persistence

2 participants