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.

Feature request: add global handling for unhandled promise rejection

See original GitHub issue

As explained at http://thecodebarbarian.com/unhandled-promise-rejections-in-node.js.html, given now “promise heavy” is current api, this is very useful for debugging.

I’d like you to consider:

  1. Automatic logging into console of all unhandled promise rejections,
  2. Addition of unhandledRejectionEvent event to application, similar to current uncaughtErrorEvent one.
<bountysource-plugin>

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource. </bountysource-plugin>

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:3
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
sserdyukcommented, Jul 10, 2017

@tsonevn I am not sure how tracing is related to the subject. Tracing is tracing, error handling is error handling. Right now exceptions inside promise then chains fail silently, and require wrapping all promise calls with catch clauses. While it’s possible to do, it’s burdensome and inefficient. It’s somewhat similar to wrapping all calls in try / catch, which luckily no-one has to do.

0reactions
CoreyColecommented, Aug 25, 2018

Although it might be burdensome to add catch statements everywhere, it’s probably a good idea. Node will soon require that you always catch errors on promises, or it will exit the process

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 code.

It’s also a good idea because oftentimes you can recover from an error in a catch(). If it was a global catch, the best you could most-likely do would be exit/restart the application

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create a Global Promise Rejection Handler | Pluralsight
This guide will demonstrate how to take this a step further and add a global promise rejection handler so that you can capture...
Read more >
Unhandled Promise Rejections in Node.js - The Code Barbarian
The node process global has an unhandledRejection event for unhandled promise rejection. Bluebird also emits this event, so if you do global.
Read more >
unhandled promise rejection with react app - Stack Overflow
So I tried to run npm start and i got : "(node:4786) UnhandledPromiseRejectionWarning: Unhandled promise rejection ...
Read more >
Node.js 15 Is Out! What Does It Mean for You? - Maxim Orlov
// Global handler for unhandled promise rejections process.on('unhandledRejection', (reason, promise) => ...
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 >

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