News for hackers. Stuff that matters.
Re:Node v6.6.0 by STRiDEX on Thursday September 15, 2016 @05:25PM (#12509937)
Been waiting for promises: Unhandled rejections now emit a process warning after the first tick. I'm not sure how useful the warning is though.

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

Re:Node v6.6.0 by danneu on Thursday September 15, 2016 @06:55PM (#12510547)
This will save a lot of time across the Node ecosystem.

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?"

Re:Node v6.6.0 by jamesrom on Thursday September 15, 2016 @08:28PM (#12511054)
Sometimes you just want an error to bubble up and be caught above. There's absolutely no reason to catch every rejection in the scope where the promise was created.
Re:Node v6.6.0 by danneu on Thursday September 15, 2016 @08:59PM (#12511189)
Yeah, looks like it just checks on nextTick, so it only warns when you don't attach a handler synchronously. Versus warning only if it's unreachable (like on garbage collection).

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.

Re:Node v6.6.0 by tlrobinson on Thursday September 15, 2016 @06:58PM (#12510564)
It will at least print the rejection value coerced to a string ("undefined" in your example), but line numbers would be nice.
Re:Node v6.6.0 by Noseshine on Friday September 16, 2016 @12:29AM (#12511830)
What will it give you what 'unhandledRejection' [0] doesn't?

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

Re:Node v6.6.0 by _greim_ on Friday September 16, 2016 @12:50AM (#12511915)
It will hopefully remind you that you forgot to register that event.