Skip to content

ErrorBoundary errors are being incorrectly marked as unhandled since 5.9.2 #10985

Closed
@julianD77

Description

@julianD77

OS:

  • Windows
  • MacOS
  • Linux

Platform:

  • iOS
  • Android

SDK:

  • @sentry/react-native (>= 1.0.0)
  • react-native-sentry (<= 0.43.2)

SDK version: 5.15.2

react-native version: 0.72.9
react version: 18.2.0

Are you using Expo?

  • Yes
  • No

Are you using sentry.io or on-premise?

  • sentry.io (SaaS)
  • on-premise

If you are using sentry.io, please post a link to your issue so we can take a look:

Issue where the error is classified as unhandled
https://mixcloud.sentry.io/discover/ios:45b823357fd441a6bb2ccc68581d293e

Issue (in older release) where the same error is classified as handled
https://mixcloud.sentry.io/discover/ios:18fd9d35a97c4f49a920b4d1ca465d25

Configuration:

Sentry.init({
  dsn: env.SENTRY,
  ignoreErrors: IGNORE_ERRORS,
  environment: IS_DEVELOPMENT_BUILD ? 'development' : 'production',
  debug: IS_DEVELOPMENT_BUILD,
  release: sentryRelease,
  dist: getBuildNumber()
});

I have the following issue:

Some Javascript errors that are being thrown explicitly by our Application code are being reported as Unhandled i.e. handled: false in Sentry - yet the code that throws the error is surrounded by an ErrorBoundary and does not result in a hard crash when the error occurs. The fallback component we provide to the error boundary is triggered.

Potentially relevant is the fact that in older releases of our App where we were using react-native 0.66.5, react 17.0.2 and sentry/react-native version 4.15.0 the very same errors were thrown from the same code are reported as handled: true by Sentry.

Steps to reproduce:

  • Trigger code that throws an error but is contained within an ErrorBoundary, such as :

ExampleComponent

    ...
    if (!cloudcast) {
        throw new Error(`No cloudcast found for id ${cloudcastId}`);
    }
    ...

Surrounding ErrorBoundary

            <ErrorBoundary
                fallback={fallback}
                onBack={onBack}
                onRetry={onRetry}
            >
                <OfflineBoundary fallback={fallback}>
                    <React.Suspense fallback={fallback}>
                        <ExampleComponent>
                    </React.Suspense>
                </OfflineBoundary>
            </ErrorBoundary>

Actual result:

  • The fallback component renders but the error is reported to Sentry and classified as unhandled

Expected result:

  • The fallback component renders and the error is reported to Sentry and classified as handled, since it has been caught by an ErrorBoundary

Is the fact that in the Sentry issue UX (and the JSON for error) the metadata.type is React ErrorBoundary Error in the newer release where the error is classified as unhandled, and Error in the older release where the error is correctly classified as handled? As mentioned the relevant application code has not changed - but the underlying RN dependencies have.

Here is a screenshot showing the same error across the two different releases, the left-hand side is our newer release using RN0.72.9 where the error is classified as unhandled. The right-hand side is the older release where the error is classified as handled.

Sentry-unhandled-error

Can anyone think of any reason why the same error scenarios are now being classified as Unhandled by Sentry?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions