Skip to content

fix(android): Capture native exceptions swallowed by Expo's bridgeless error handling#5898

Merged
alwx merged 2 commits intomainfrom
alwx/improvement/5868
Mar 26, 2026
Merged

fix(android): Capture native exceptions swallowed by Expo's bridgeless error handling#5898
alwx merged 2 commits intomainfrom
alwx/improvement/5868

Conversation

@alwx
Copy link
Contributor

@alwx alwx commented Mar 26, 2026

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

On Expo SDK 53+ Android apps, ExpoReactHostDelegate.handleInstanceException iterates registered ReactNativeHostHandlers but does not rethrow the exception. This causes native crashes (e.g., IllegalStateException from Fabric's SurfaceMountingManager) caught by React Native's GuardedFrameCallback to be silently swallowed — they never reach Java's UncaughtExceptionHandler, which sentry-java relies on for crash capture.

This PR registers a ReactNativeHostHandler via Expo's Package system that intercepts these exceptions and captures them directly through Sentry.captureException() with an unhandled mechanism (type="expoReactHost", handled=false).

📝 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
  • No breaking changes

@github-actions
Copy link
Contributor

github-actions bot commented Mar 26, 2026

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(android): Capture native exceptions swallowed by Expo's bridgeless error handling by alwx in #5898
  • Fix(Replay): dont record ignored/dropped errors by lucas-zimerman in #5885
  • fix(android): Capture native exceptions consumed by Expo's bridgeless error handling by alwx in #5871
  • chore(core): Upgrade TypeScript from 4.9.5 to 5.9.3 by antonis in #5886
  • chore(deps): update JavaScript SDK to v10.46.0 by github-actions in #5890
  • chore(deps): update CLI to v3.3.4 by github-actions in #5891
  • chore(deps): bump picomatch from 2.3.1 to 2.3.2 by dependabot in #5889
  • fix(core): Fix stale deprecation references by antonis in #5881
  • chore(build): Rename version-bump.js to bump-version.js by antonis in #5883
  • chore(deps): bump activesupport from 7.0.8.6 to 7.2.3.1 in /samples/react-native-macos by dependabot in #5870
  • chore(deps): bump activesupport from 6.1.7.10 to 7.2.3.1 in /samples/react-native by dependabot in #5869
  • chore(deps): bump yauzl to ^3.2.1 by antonis in #5855
  • chore(deps): bump appium from 2.4.1 to 3.2.2 by antonis in #5856
  • fix(ios): Guard replay postInit behind runtime session replay check by antonis in #5858
  • Add better needs_web check to CI by alwx in #5863
  • chore(deps): bump fast-xml-parser to ^5.5.7 by antonis in #5854
  • CI: detect-changes workflow to only check the affected components on the CI side by alwx in #5843
  • chore(deps): bump getsentry/craft/.github/workflows/changelog-preview.yml from 2.24.1 to 2.25.0 by dependabot in #5861
  • chore(deps): bump getsentry/craft from 2.24.1 to 2.25.0 by dependabot in #5862
  • chore(deps): bump github/codeql-action from 4.32.6 to 4.34.1 by dependabot in #5860
  • chore(deps): update JavaScript SDK to v10.45.0 by github-actions in #5848
  • chore(deps): bump flatted from 3.4.1 to 3.4.2 by dependabot in #5853
  • chore(deps): update Cocoa SDK to v9.8.0 by github-actions in #5847
  • fix(tracing): Guard getNewScreenTimeToDisplay behind enableTimeToInitialDisplay by antonis in #5849

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.
@alwx alwx force-pushed the alwx/improvement/5868 branch from b7fdeb6 to f24926f Compare March 26, 2026 11:56
@github-actions
Copy link
Contributor

github-actions bot commented Mar 26, 2026

Fails
🚫 Please consider adding a changelog entry for the next release.

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

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 #skip-changelog to the PR description or adding a skip-changelog label.

Generated by 🚫 dangerJS against 4b01cd5

@alwx alwx marked this pull request as ready for review March 26, 2026 11:57
@alwx alwx added the ready-to-merge Triggers the full CI test suite label Mar 26, 2026
Copy link
Contributor

@antonis antonis left a comment

Choose a reason for hiding this comment

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

The fix LGMT and worked on my local tests 🚀
Let's wait for the CI checks and merge.

@alwx alwx merged commit 208f590 into main Mar 26, 2026
91 of 106 checks passed
@alwx alwx deleted the alwx/improvement/5868 branch March 26, 2026 12:17
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.

2 participants