Repository navigation
Conversation
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.
Semver Impact of This PR⚪ None (no version bump detected) 📋 Changelog PreviewThis is how your changes will appear in the changelog.
🤖 This preview updates automatically when you update the PR. |
📲 Install BuildsAndroid
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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
left a comment
There was a problem hiding this comment.
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 => { |
There was a problem hiding this comment.
m: Could we use a fillTyped like
There was a problem hiding this comment.
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.
antonis
left a comment
There was a problem hiding this comment.
LGTM 🚀
Tested locally and verified the fix. Sentry link: https://sentry-sdks.sentry.io/issues/7863025243/?project=5428561&query=is%3Aunresolved&referrer=issue-stream

📢 Type of change
📜 Description
The
ReactNativeErrorHandlersintegration now also wraps React Native'sExceptionsManager.handleException. Fatal calls go through the same capture path asErrorUtilsfatals (levelfatal, mechanismonerror, 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 rootonUncaughtErrorcallback directly toExceptionsManager. 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
sendDefaultPIIis enabled.🔮 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.