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:
- Install sentry with minimal config
- Generate an unhandled promise rejection
Actual result:
Yellow box appears but no error logged to sentry.io
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
- fix: Fix unhandled promise rejections not being tracked (#1367) Fixes #1077 — committed to getsentry/sentry-react-native by jennmueng 3 years ago
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
promisein my package.json:@jennmueng your fix does not work. You expect
Promise._Yto store the_onHandlebut duringpromisemodule’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_onHandleof the globalPromisenor to the_onHandleof modulepromise. A solution may be to remove sentry dependency onpromisemodule and to use a peer dependency instead, so that you can require the only and so the rightpromise/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.jsonas a workaround until fbjs dependencies are upgraded:@cruzach maybe sentry should hook itself directly on
Promiseglobal object aspromise/setimmediate/rejection-trackingdoes and instead of using it. It would avoid the issue to reappear. Or add to the doc that there must be only one version ofpromisemodule per project.