Replies: 3 comments 5 replies
-
I believe Hermes already provided unhandled rejection tracking through Here's how we use it to capture unhandled promise rejections in React Native: https://github.com/Instabug/Instabug-React-Native/blob/master/src/utils/UnhandledRejectionTracking.ts |
Beta Was this translation helpful? Give feedback.
-
Absolutely huge pain point for me that I deal with daily. I rarely get useful traces to the cause of an error. It gets even worse for npm packages where it often won’t mention the package. Super excited for improvements here. |
Beta Was this translation helpful? Give feedback.
-
Managed to get this working and will hopefully be merged soon. Closing this discussion. |
Beta Was this translation helpful? Give feedback.
-
Problem
For a very long time when a promise rejects without an attached handler we get this warning screen without a correct stack trace, only some internal calls to the RN internals.
If you navigate to the anon function pointed in the error message you can see it is the babel transpiled version of the promise:
Is there anyway to reverse this and get the original line number?
I would like to contribute getting proper stack traces shown to the developer, this would be a major improvement to the DX of RN. I however do not have any experience with the internals of RN, so I'm dumping the info I have here, with the hopes of also getting some guidance from the core contributors to see if this can be improved.
Info
From what I've managed to gather and understand, currently, RN uses a Promise polyfill (why? JSC limitation). Apparently also JSC does not expose what is called
HostPromiseRejectionTracker
which would actually allow to get the correct traces. This info was provided in this thread on twitter by the folks at expo.Now that RN is shipping with hermes by default we could 1. make sure that Hermes is exposing
HostPromiseRejectionTracker
and 2. check if RN is running on JSC or Hermes and if Hermes is used do not use the polyfill. This should allow us to get the proper stack traces.I would gladly partake in this task if someone could guide me a bit in the internals of Hermes/RN.
Beta Was this translation helpful? Give feedback.
All reactions