sentry-react-native: Unhandled promises are not logged at all (iOS and Android)

Platform:

  • iOS

SDK:

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

SDK version:@sentry/react-native”: “^1.7.2”,

react-native version: “react-native”: “^0.63.2”,

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:

No issue was created

Configuration:

(@sentry/react-native)

Sentry.init({
  dsn: 'https://...@sentry.io/...'
  // no extra options
});

I have following issue:

Normal exceptions are logged to Sentry.io just fine, but unhandled promises are not logged at all. My understanding is that this should happen by default. I do get a yellow box showing the unhandled exception but it seems that Sentry never sees it.

This repros on both Android and iOS.

Steps to reproduce:

  1. Install sentry with minimal config
  2. Generate an unhandled promise rejection

Actual result:

Yellow box appears but no error logged to sentry.io

image

Expected result:

Unhandled promise rejections are logged to sentry.io

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 14
  • Comments: 30 (10 by maintainers)

Commits related to this issue

Most upvoted comments

I have reproduced the issue and confirmed that unhandled promise rejections are not being caught on my end as well. Adding this to our immediate TODO.

@jer-sen We’re going to add a troubleshooting/install doc and I like your second idea, we will try it out and add that in.

It looks like I’ve managed to make it work by forcing the particular version of promise in my package.json:

 "resolutions": {
    "promise": "^8.1.0"
  },

@jennmueng your fix does not work. You expect Promise._Y to store the _onHandle but during promise module’s build a random name is chosen depending on a hash of the source code (cf https://github.com/then/promise/blob/91b7b4cb6ad0cacc1c70560677458fe0aac2fa67/build.js#L16). So you can not access directly to the _onHandle of the global Promise nor to the _onHandle of module promise. A solution may be to remove sentry dependency on promise module and to use a peer dependency instead, so that you can require the only and so the right promise/setimmediate/core. Once again, its a major issue, please fix it quickly.

@cruzach you are right but its a big issue since it makes sentry nearly useless! With Expo you can add this to your package.json as a workaround until fbjs dependencies are upgraded:

  "resolutions": {
    "expo/**/promise": "^8.0.3"
  },

@cruzach maybe sentry should hook itself directly on Promise global object as promise/setimmediate/rejection-tracking does and instead of using it. It would avoid the issue to reappear. Or add to the doc that there must be only one version of promise module per project.