Skip to content

Support capturing native Android exceptions intercepted by Expo's error handler #5868

@Kobby-Bawuah

Description

@Kobby-Bawuah

Problem Statement

On Expo SDK 53 Android apps, certain native exceptions (e.g., IllegalStateException from Fabric's SurfaceMountingManager) are caught by React Native's GuardedFrameCallback and routed through ReactHostImpl.handleHostException → handleInstanceException. Expo overrides handleInstanceException in its ExpoReactHostDelegate, which passes the error to registered hostHandlers (such as expo-updates) but does not rethrow it. Since hostHandlers is never empty in practice, the exception never reaches Java's UncaughtExceptionHandler, which is the mechanism sentry-java relies on to capture crashes.

The result is that reproducible native Android crashes go completely unreported in Sentry. The Sentry SDK itself works correctly, when the rethrow is forced, the event is captured with the expected UncaughtExceptionHandler mechanism. The problem is the exception never reaches the SDK.

This is complicated by the fact that expo-updates has a legitimate reason to intercept these errors (for OTA update rollback/error recovery), so simply rethrowing is not a viable solution, it would break expo-updates error recovery.

Related Expo PR: expo/expo#37021

Solution Brainstorm

Explore options for the SDK to capture these exceptions at a level before they are consumed by Expo's handler chain. One possibility is hooking into Expo's ReactNativeHostHandler interface, though that would introduce a dependency on Expo. There may be other approaches worth considering.

If the team feels this is best addressed on Expo's side rather than ours, please flag that so we can communicate it back to the customer, they are also in contact with the Expo team.

Are you willing to submit a PR?

None

Metadata

Metadata

Assignees

No fields configured for issues without a type.

Projects

Status

Waiting for: Product Owner

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions