Ios hard to debug undefined in _promiseRejectionHandler

2 month ago, after an upgrade of raven-js > 3.23 ( I started receiving errors as noted in the release note.

The error is hard to debug: the message is undefined and the stack is (raven-js 3.25.2)

at captureMessage(…/node_modules/raven-js/src/raven.js:583:1)
at captureException(…/node_modules/raven-js/src/raven.js:507:1)
at _promiseRejectionHandler(…/node_modules/raven-js/src/raven.js:431:1)
at _promiseRejectionHandler([native code])

The breacrumb does not help me to debug (I can’t find a pattern that trigger the error). However I noticed that this error happens 98% on iPad.

How would you do to debug this error?
Thanks for your help,

@nicgirault did you find a way to debug those errors from the _promiseRejectionHandler? We receive a lot of similar errors.

No it’s still a major issue for us

After some investigation and experiments I found a workaround:
add a .catch for all promises and send the error to the Sentry manually.

  .get('/load-user-details-api/', { some-arguments })
  .catch((error) => {
     Raven.captureMessage(`Load user details: ${error}`);

Long explanation:

Browsers don’t have a stack trace if an error occurs in a promise. Having a handler for the ‘error’ or ‘unhandledrejection’ events doesn’t help either.

In the other words: unhandled errors in promises will always be as undefined without any stack trace.

The only workaround I found for now is to have a .catch for each promise. After adding a .catch for some promises showed that the number of undefined errors decreased significantly.

The .catch handler is also a good practice as you don’t leave unhandled errors. You can fail silently, log error or show a modal to a user. But it will be clear from the code, that a promise have a meaningful error handler.

Hope it will help.