question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for "Unhandled promise rejection" / "Uncaught (in promise)"

See original GitHub issue

Example use case (JSBin):

var p = new Promise(function(resolve, reject) {
    window.setTimeout(
        function() {
            reject();
        }, 10);
});

p.then(function () {
    console.log('done!');
});

If the promise throws an exception, and there’s no error handler, the browser will spit out an uncaught promise error.

image

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:18
  • Comments:41 (19 by maintainers)

github_iconTop GitHub Comments

14reactions
MarkMurphycommented, Nov 10, 2016

what’s the TL;DR solution here?

12reactions
benvinegarcommented, Nov 18, 2015

@joaocunha – looking at the code above, it looks like you could do the following as a workaround:

window.onunhandledrejection = function(data) {
    Raven.captureException(data.reason);
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Tracking Unhandled Promise Rejections - TrackJS
When a promise is rejected, it looks for a rejection handler. If it finds one, like in the example above, it calls the...
Read more >
What is an unhandled promise rejection? - Stack Overflow
Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit...
Read more >
Handling those unhandled promise rejections with JS async ...
[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was ......
Read more >
Window: unhandledrejection event - Web APIs | MDN
The unhandledrejection event is sent to the global scope of a script when a JavaScript Promise that has no rejection handler is rejected; ......
Read more >
Unhandled Promise Rejections in Node.js - The Code Barbarian
Note that, while the error parameter to the 'unhandledRejection' event should be a JavaScript error, it doesn't necessarily have to be. Calling ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found