bugsnag-js
bugsnag-js copied to clipboard
React Native - Possible Unhandled Promise Rejections
Similar issue as in https://github.com/bugsnag/bugsnag-js/issues/1519, but I can't even get it working in a brand new create react app. Posted a comment on that issue. Creating this issue for more visibility.
Describe the bug
When Errors (such as TypeError) happen within an Async function that's not wrapped in a try/catch (such as a function used for the onPress prop), they are not reported to BugSnag.
Steps to reproduce
- Create a new React Native project using
npx react-native init BugSnagUnhandledRejections --version 0.65.2 - Install BugSnag using
npx @bugsnag/react-native-cli init, and choose latest (7.17.3)- Add appropriate
API_KEYwhen prompted
- Add appropriate
- Add
Bugsnag.start()toAppcomponent. - Add a button which calls an
asyncfunction when pressed - See warning log in bundler console, but nothing in Bugsnag
- For more robust testing, have a non-async function be called for
onPressand don'tawaitthe async function when calling (or wrap in a try/catch)
Environment
- Bugsnag version: 7.17.3
- React-Native: 0.65.2
- React: 17.0.2
- Device (e.g. iphonex): iPhone Simulator and OnePlus 6T
Example code snippet
// Step 5
const boom = async () => {
null.reject();
};
// Step 7
const asyncPress = async () => {
Bugsnag.notify(new Error('create-react app test'));
await boom();
};
// Step 7
const press = () => {
asyncPress();
null.goBoom();
};
Error messages:
| Not Logged | Logged |
|---|---|
![]() |
![]() |
Hi @ians-shipt - thanks for raising this, I've been able to reproduce this on v0.65 of React Native as per your steps above, but not on v0.64. We're currently investigating and will keep you updated on this thread 👍
Hi @ians-shipt - please could you confirm whether you are only seeing this for dev builds?
Based on the investigation we have done so far, we have a theory that this only happens in dev mode when React Native lazy loads promise rejection handling after Bugsnag has started, but it would be good to confirm that before we implement a workaround!
Hi @luke-belton , apologies for the delayed response!
It would seem this is reproducible even when the test app is not in dev mode. I ran the app on my OnePlus 6T using npx react-native run-android --variant=release and making sure the Metro bundler was not running.
Below is what I see in BugSnag (same as before, the null.reject doesn't get logged)
Hey @luke-belton , we've upgraded ReactNative and no longer appear to be seeing this, so I'll close this issue out. Thanks to you and the team for looking into it!
@ians-shipt I'm facing a similar issue, to which React Native version did you upgrade to solve this problem?
@andrecrimb Sorry for the delayed response! We went from 0.65.2 to 0.68.3

