4 ms·
Not if I can help it :) In io.js this is no longer an issue, you have a process event you can catch on "silent errors" to make them loud. This lands in NodeJS s
by inglor 11y ago
Not if I can help it :) In io.js this is no longer an issue, you have a process event you can catch on "silent errors" to make them loud. This lands in NodeJS soon. Bluebird promises don't behave this way and have never done so.
- grandalf 11y agogreat! BTW would you use bluebird or es6 promises if starting a new project today?
- phpnode 11y agoinglor is a contributor to Bluebird, so I'd guess he'd say Bluebird. Bluebird is the much faster option and has a lot more features, if you're using babel (and a recent node/io.js) you can transpile async/await to bluebird coroutines for maximum performance and syntactic beauty.
- grandalf 11y agoIs there any chance Bluebird will become the standard in the future? Not sure if it makes sense to use a nonstandard approach, but would love to be convinced otherwise.
- phs2501 11y agoIMHO, very doubtful; Bluebird has a lot of (very useful) features that would be pretty burdensome to put into a specification. On the other hand, there's really no reason not to use Bluebird. It's easy to ensure that a promise you receive is a Bluebird promise: import Bluebird from 'bluebird'; const bluebirdPromise = Bluebird.resolve(promise); If `promise` is a Bluebird promise that will be a no-op, and if it's a foreign promise or thennable you'll get a new Bluebird promise that will resolve/reject when the foreign one does. (This is standard behavior; see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...) Since Bluebird promises are thennables, the reverse will be true if they're consumed by a different promise library. Given Bluebird's speed, superior debuggability, and features, there's really no reason not to use it a this point.
- grandalf 11y agothanks much for the explanation. I will try bluebird.
- elliotf 11y agoMaybe there's a nuance between "possibly unhandled" and "unhandled" ? I was bitten by bluebird quietly eating exceptions on at least one codebase. I fixed it by re-throwing them via: https://github.com/petkaantonov/bluebird/blob/master/API.md#promiseonpossiblyunhandledrejectionfunction-handler---undefined https://github.com/petkaantonov/bluebird/blob/master/API.md#... edit: bluebird also exposes a process-level event, now, too!