fix(android): Capture native exceptions swallowed by Expo's bridgeless error handling#5898
Merged
fix(android): Capture native exceptions swallowed by Expo's bridgeless error handling#5898
Conversation
Contributor
Semver Impact of This PR⚪ None (no version bump detected) 📋 Changelog PreviewThis is how your changes will appear in the changelog.
Plus 5 more 🤖 This preview updates automatically when you update the PR. |
…s error handling On Expo SDK 53+ Android, ExpoReactHostDelegate.handleInstanceException iterates registered ReactNativeHostHandlers but does not rethrow. This means native crashes caught by React Native's GuardedFrameCallback never reach Java's UncaughtExceptionHandler, which sentry-java relies on. Register a ReactNativeHostHandler via Expo's Package system that captures these exceptions through Sentry.captureException with an unhandled mechanism (type=expoReactHost, handled=false). The handler lives in a separate Android library project (android/expo-handler/) to avoid Gradle codegen conflicts between Expo and RN autolinking. The expo-module.config.json registers it as :sentry-react-native-expo. Non-Expo builds are unaffected.
b7fdeb6 to
f24926f
Compare
Contributor
Instructions and example for changelogPlease add an entry to Example: ## Unreleased
### Fixes
- Capture native exceptions swallowed by Expo's bridgeless error handling ([#5898](https://github.com/getsentry/sentry-react-native/pull/5898))If none of the above apply, you can opt out of this check by adding |
antonis
approved these changes
Mar 26, 2026
Contributor
antonis
left a comment
There was a problem hiding this comment.
The fix LGMT and worked on my local tests 🚀
Let's wait for the CI checks and merge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📢 Type of change
📜 Description
On Expo SDK 53+ Android apps,
ExpoReactHostDelegate.handleInstanceExceptioniterates registeredReactNativeHostHandlers but does not rethrow the exception. This causes native crashes (e.g.,IllegalStateExceptionfrom Fabric'sSurfaceMountingManager) caught by React Native'sGuardedFrameCallbackto be silently swallowed — they never reach Java'sUncaughtExceptionHandler, whichsentry-javarelies on for crash capture.This PR registers a
ReactNativeHostHandlervia Expo's Package system that intercepts these exceptions and captures them directly throughSentry.captureException()with an unhandled mechanism (type="expoReactHost",handled=false).📝 Checklist
sendDefaultPIIis enabled