Sentry-react-native: Sentry silences "Possible Unhandled Promise Rejection" locally, while reporting them correctly.

Created on 15 Mar 2019  路  7Comments  路  Source: getsentry/sentry-react-native

Since upgrading both react native (58.6) and sentry (0.42.0) I have run into the critical issue of these warnings not appearing locally in my debugging console, but being sent to sentry. Disabling sentry makes them appear again.

Is there some new setting, which silences them?

If this is intended behavior I would strongly be in favor of having the default settings still throw warnings and errors locally.

馃react-native-sentry

Most helpful comment

Co-sign. We're actually experiencing crashes in Sentry on unhandled promise rejections - I would love for Sentry to not report these at all, or at least be configurable.

All 7 comments

Co-sign. We're actually experiencing crashes in Sentry on unhandled promise rejections - I would love for Sentry to not report these at all, or at least be configurable.

any update on this? I would like it to be configurable too

I am closing all old issues, please if this is still a problem feel free to revive it.
Also, consider moving to our new SDK @sentry/react-native if it still happens there please open a new issue.

This is still an (IMO at least annoying, at worst pretty dangerous) issue with sentry. See here: https://github.com/getsentry/sentry-javascript/issues/1909

The problem is still there, cause @sentry/react-native SDK is using its ReactNativeErrorHandlers (but not Globalhandlers).

The workaround by now is adding this yourself and disable the default handler

Sentry.init({
  ...options
   integrations: [
    new Sentry.Integrations.ReactNativeErrorHandlers({
      onunhandledrejection: false,
    }),
  ],
});

const tracking = require('promise/setimmediate/rejection-tracking');

  tracking.disable();
  tracking.enable({
    allRejections: true,
    onHandled: () => {
      // We do nothing
    },
    onUnhandled: (id: any, error: any) => {
      console.warn(error.stack);
      Sentry.captureException(error);
    },
  });

To solve this
what if we do:

onUnhandled: (id: any, error: any) => {
          if (__DEV__) {
            console.warn(id, error);
          }
          getCurrentHub().captureException(error, {
            data: { id },
            originalException: error
          });
        }

that should solve it, right?

The problem is still there, cause @sentry/react-native SDK is using its ReactNativeErrorHandlers (but not Globalhandlers).

The workaround by now is adding this yourself and disable the default handler

Sentry.init({
  ...options
   integrations: [
    new Sentry.Integrations.ReactNativeErrorHandlers({
      onunhandledrejection: false,
    }),
  ],
});

const tracking = require('promise/setimmediate/rejection-tracking');

  tracking.disable();
  tracking.enable({
    allRejections: true,
    onHandled: () => {
      // We do nothing
    },
    onUnhandled: (id: any, error: any) => {
      console.warn(error.stack);
      Sentry.captureException(error);
    },
  });

Hey. does using const tracking = require('promise/setimmediate/rejection-tracking');

This has any side negative impact on performance of app?

Also why we need to disable it before, enabling it?

Was this page helpful?
0 / 5 - 0 ratings