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. |
| import { ReactNativeLibraries } from '../utils/rnlibraries'; | ||
| import { RN_GLOBAL_OBJ } from '../utils/worldwide'; | ||
| import { hasInterestedSubscribers, publishGlobalError } from './globalErrorBus'; | ||
| import { checkPromiseAndWarn, polyfillPromise, requireRejectionTracking } from './reactnativeerrorhandlersutils'; |
There was a problem hiding this comment.
A rejected fatal-event flush prevents React Native from handling the crash
When a fatal reaches the wrapper with no interested GlobalErrorBoundary and client.flush() rejects, the original React Native ExceptionsManager.handleException is never called; the rejection branch only logs and resets the latch. Ensure the fatal is reported to React Native when Sentry handling fails.
Evidence
- The new
ExceptionsManager.handleExceptionwrapper passes fatal errors tohandleErrorwithreportas the callback for invoking React Native’s original handler. - In production,
handleErrorcallsreportfrom the flush fulfillment path when no interested boundary exists; its flush rejection handler only logs and resetshandlingFatal. - Therefore, if the flush rejects for a fatal with no interested boundary, the original handler is skipped. The test for the normal path expects it to be called after the flush resolves.
Identified by Warden · code-review · UGK-TYK
There was a problem hiding this comment.
Looks valid but probably an edge case 🤔
📲 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.
| } | ||
| handleError(error, isFatal, report).catch((e: unknown) => { | ||
| debug.error('[ReactNativeErrorHandlers] Failed to handle the fatal error.', e); | ||
| }); |
There was a problem hiding this comment.
Failed fatals skip native reporting
Medium Severity
The new ExceptionsManager.handleException wrapper intercepts fatals and only calls the original handler through report(). If handleError rejects, the .catch() logs and returns, so React Native never sees the exception. A render error that this change intercepts is then dropped: no Sentry event, no native crash, and a broken tree left on screen.
Additional Locations (1)
Triggered by project rule: PR Review Guidelines for Cursor Bot
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
| import { ReactNativeLibraries } from '../utils/rnlibraries'; | ||
| import { RN_GLOBAL_OBJ } from '../utils/worldwide'; | ||
| import { hasInterestedSubscribers, publishGlobalError } from './globalErrorBus'; | ||
| import { checkPromiseAndWarn, polyfillPromise, requireRejectionTracking } from './reactnativeerrorhandlersutils'; |
There was a problem hiding this comment.
Looks valid but probably an edge case 🤔
| } | ||
| handleError(error, isFatal, report).catch((e: unknown) => { | ||
| debug.error('[ReactNativeErrorHandlers] Failed to handle the fatal error.', e); | ||
| }); |
| 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


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