Now using node v6.6.0 (npm v3.10.3)
$ node
> Promise.reject()
Promise { <rejected> undefined }
> (node:85928) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): undefined
Now using node v6.6.0 (npm v3.10.3)
$ node
> Promise.reject()
Promise { <rejected> undefined }
> (node:85928) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): undefined
Forgetting to handle rejection is probably the most common error I see when people post Promise snippets in #node.js. Silent failure is so deadly. "Why do my requests hang?"
Though it does emit another message when rejection is handled asynchronously.
> var p = new Promise((_, reject) => reject('lol')) \
setTimeout(() => p.catch(() => console.log('handled')), 0)
UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 5): lol
PromiseRejectionHandledWarning: Rejection handled asynchronously (rejection id: 5)
Consolation prize?Fortunately, most of the run of the mill promises I can think of off the top of my head get rejection handlers attached synchronously, like in upstream middleware. I might be drawing a blank, though.
I don't mind that it also emits a warning, but AFAIK you could already get that information by subscribing to this more specific event?
[0] https://nodejs.org/dist/latest-v6.x/docs/api/process.html#pr...