Unhandled Promise rejections

Using Promise and async functions automatically channels errors in a useful direction.  Errors will cause a Promise to flip into a rejected state, which must eventually be handled in a .catch method.  Since we're all human, we're bound to forget to ensure that all code paths handle their rejected Promise's.

Currently, Node.js prints the following warning if it detects an unhandled Promise rejection:

(node:4796) UnhandledPromiseRejectionWarning: Unhandled promise rejection 

The warning goes on to say that the default handler for unhandled Promise rejection has been deprecated and that such Promise rejections will crash the Node process rather than print this message. The built-in process module does emit an event ...

Get Node.js Web Development - Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.