Bluebird is a really nice project. I especially like the error handling semantics it adopts by default.
However, when using .nodeify I have encountered some troubling behavior. I brought this up yesterday on IRC, and @spion thought it could be a bug. So I am raising the issue here for further discussion
var log = console.log.bind(console)
function doStuff(callback) {
return new Promise(function (resolve, reject) {
reject(new Error("example error"));
})
.nodeify(callback);
}
function doStuff2(callback) {
return doStuff(callback).finally(log); // or ".then"
}
doStuff(log);
doStuff2(log); // possibly unhandled exception
When I call doStuff(log), the log becomes my error handler, as it is passed into .nodeify. Bluebird considers this error to be handled in this case.
doStuff2(log) internally calls doStuff(log) and so I would expect that the error would be satisfied by the log callback, but upon attaching finally (or then) handlers, it seems to somehow revive the error from doStuff, and logs a "possibly unhandled exception" stack trace to the console.
I'm not sure if it's a bug, but I would like to understand why this occurs, if it is determined to be the expected behavior, so that I can avoid writing code that might cause this behavior.
Bluebird is a really nice project. I especially like the error handling semantics it adopts by default.
However, when using
.nodeifyI have encountered some troubling behavior. I brought this up yesterday on IRC, and @spion thought it could be a bug. So I am raising the issue here for further discussionWhen I call
doStuff(log), thelogbecomes my error handler, as it is passed into.nodeify. Bluebird considers this error to be handled in this case.doStuff2(log)internally callsdoStuff(log)and so I would expect that the error would be satisfied by thelogcallback, but upon attachingfinally(orthen) handlers, it seems to somehow revive the error fromdoStuff, and logs a "possibly unhandled exception" stack trace to the console.I'm not sure if it's a bug, but I would like to understand why this occurs, if it is determined to be the expected behavior, so that I can avoid writing code that might cause this behavior.