Skip to content

fix(core): Capture uncaught render errors on React Native 0.78+ - #7078

Open
alwx wants to merge 3 commits into
mainfrom
alwx/bugfix/7043
Open

alwx wants to merge 3 commits into
mainfrom
alwx/bugfix/7043

Conversation

@alwx

@alwx alwx commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

The ReactNativeErrorHandlers integration now also wraps React Native's ExceptionsManager.handleException. Fatal calls go through the same capture path as ErrorUtils fatals (level fatal, mechanism onerror, flush, then report to React Native). Non-fatal calls, such as errors that an error boundary catches, pass through. A fatal that the integration already forwarded to React Native passes through too, so each crash is captured once.

💡 Motivation and Context

Since React 19 (React Native 0.78), a render error that no error boundary catches skips ErrorUtils. React Native reports it from the root onUncaughtError callback directly to ExceptionsManager. The native SDKs drop the resulting crash because they expect the JS layer to report it, so Sentry gets nothing on Android and iOS. Fixes #7043.

💚 How did you test it?

Added unit tests for the render path, the error boundary path, and both duplicate guards. On the React Native sample (0.88.1, New Architecture, Android release build, emulator), a render error outside any error boundary was lost before this change and is captured as a fatal event after it. A fatal thrown in a button handler is still captured once.

📝 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

Update the error boundary docs. They say that only some render errors on Android skip the global handler, but on React Native 0.78+ every uncaught render error does.

alwx added 2 commits November 20, 2026 10:23
React 19 does not rethrow a render error that no error boundary catches.
React Native passes it from the root onUncaughtError callback straight to
ExceptionsManager.handleException as a fatal, so the ErrorUtils global
handler never runs. The native SDKs then drop the crash because they expect
the JS layer to report every fatal JS error (JavascriptException on Android,
"Unhandled JS Exception" on iOS). The app crashes and Sentry gets nothing.

The ReactNativeErrorHandlers integration now also wraps
ExceptionsManager.handleException. Fatal calls go through the same capture
path as ErrorUtils fatals (level fatal, mechanism onerror, flush, then report
to React Native). Non-fatal calls, such as errors that an error boundary
catches, pass straight through.

The ErrorUtils handler forwards its fatal to React Native's default handler,
which calls handleException too. To capture each fatal once, a fatal that
the integration forwards passes straight through. A flag covers the
synchronous forward, and a WeakSet covers a previous handler that reports
the error to React Native later.

ExceptionsManager is read through ReactNativeLibraries, so web bundles do
not include it.

Fixes #7043
Replace the placeholder PR number in the CHANGELOG entry with #7078.
@github-actions

github-actions Bot commented Nov 20, 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): Capture uncaught render errors on React Native 0.78+ by alwx in #7078
  • chore(deps): bump getsentry/craft from 3.12.0 to 3.13.0 by dependabot in #7083
  • chore(deps): bump getsentry/craft/.github/workflows/changelog-preview.yml from 3.12.0 to 3.13.0 by dependabot in #7082
  • chore(deps): bump getsentry/github-workflows/danger from 6bf4a27612e388f9c113d64f75e25190e814b414 to bce11fe6eaa86dbb9d360ab45a96e659828877f0 by dependabot in #7081
  • chore(deps): bump actions/create-github-app-token from 3.3.0 to 3.4.0 by dependabot in #7085
  • chore(deps): bump ruby/setup-ruby from 1.338.0 to 1.342.0 by dependabot in #7084
  • chore(sample): Remove unused Detox setup from the React Native sample by antonis and claude in #7072
  • ci(ios): Build TestFlight sample with Xcode 27 by philprime with sentry-junior in #7065
  • perf(android): Create SDK view managers on demand by alwx in #7049
  • fix(core): Remove web Replay and Feedback from native bundles by default by huextrat, claude and antonis in #7062
  • fix(core): Define UnsafeObject locally instead of deep importing it by alwx in #7061
  • chore(deps): update Android SDK to v8.65.0 by github-actions in #7058

🤖 This preview updates automatically when you update the PR.

@alwx
alwx marked this pull request as ready for review November 20, 2026 11:21
@alwx alwx added the ready-to-merge Triggers the full CI test suite label Nov 20, 2026
@sentry

sentry Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

📲 Install Builds

Android

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

⚙️ sentry-react-native Build Distribution Settings

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

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 2f5fd5a. Configure here.

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

Overall looks good. Added a couple of comments along with the bot feedback.

Added unit tests for the render path, the error boundary path, and both duplicate guards. On the React Native sample (0.88.1, New Architecture, Android release build, emulator), a render error outside any error boundary was lost before this change and is captured as a fatal event after it. A fatal thrown in a button handler is still captured once.

Let's also add Sentry links for the above tests

const exceptionsManager = ReactNativeLibraries.ExceptionsManager;
const handleException = exceptionsManager?.handleException;
if (exceptionsManager && handleException) {
exceptionsManager.handleException = (error: unknown, isFatal: boolean): void => {

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.

m: Could we use a fillTyped like

fillTyped(AppRegistry, 'runApplication', originalRunApplication => {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 0443304. The wrapper now uses fillTyped, like the AppRegistry integration.

…ure it

The ExceptionsManager.handleException wrapper reported a fatal to React
Native only from the capture path. If the capture rejected, or if the flush
rejected, React Native never got the fatal. The app was then left on a broken
screen without a crash.

The wrapper now reports the fatal to React Native when the capture rejects. A
flag makes sure that React Native gets it once, also when its own handler
throws. A rejected flush now reports the fatal like a successful flush does.
This also covers ErrorUtils fatals.

The wrapper now uses fillTyped, like the AppRegistry integration.
@alwx
alwx requested a review from antonis November 23, 2026 09:31

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

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.

[Android] A render error no error boundary catches is reported neither by the JS handler nor natively (React 19 / React Native ≥ 0.78)

2 participants