React Native - Possible Unhandled Promise Rejections
See original GitHub issueSimilar 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_KEY
when prompted
- Add appropriate
- Add
Bugsnag.start()
toApp
component. - Add a button which calls an
async
function when pressed - See warning log in bundler console, but nothing in Bugsnag
- For more robust testing, have a non-async function be called for
onPress
and don’tawait
the 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 |
---|---|
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
React Native: Possible unhandled promise rejection
Click on your project in the Project Navigator · Open the Info tab · Click on the down arrow left to the "App...
Read more >Possible Unhandled Promise Rejection (id:0) #7107 - GitHub
If this object is disturbed or locked, return a new promise rejected with a TypeError. Simply said, the following is likely to produce...
Read more >React Native Auth0 Possible Unhandled Promise Rejection
Possible Unhandled Promise Rejection (id: 1): TypeError: undefined is not an object (evaluating '_yield$getCredentials.accessToken').
Read more >React Native Auth0 Possible Unhandled Promise Rejection
My understanding of the error is that it is saying, 'we can't find any value for the Auth0Module object property you are looking...
Read more >bugsnag/plugin-react-native-unhandled-rejection - Yarn
This plugin hooks in to React Native's promise rejection tracking to provide unhandled exception reporting for Promises. It is included in the Expo...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 onv0.64
. We’re currently investigating and will keep you updated on this thread 👍@ians-shipt I’m facing a similar issue, to which React Native version did you upgrade to solve this problem?