-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
I mentioned this on IRC, but I'm also going to put it here, since I think its probably not possible to automatically deal with this one :(
var BB = require('bluebird');
var BB2 = require('bluebird/js/main/promise')();
BB.cast(1).then(function() {
return BB2.cast(1).then(function() {
return makes.reference.errors();
});
}).error(function(e) {
console.log("This should not execute", e);
});This also occurs if I have a node module that depends on bluebird which I'm developing in parallel with the app that depends on it. For example, while developing anydb-sql and doxbee (which depends on anydb-sql), I can't use .error() in doxbee because that might also catch programmer errors within anydb-sql.
It gets slightly worse :( If I run npm dedupe (which is often done before browserifying or before pushing node_modules to production) the behavior of my program will change -- since now both modules will depend on the same instance of bluebird.
Anyway, in general, the assumption that an external promises-based module never has bugs is just too big -- too often this is not the case.
I realize that the situation with error types coming from most promise-based libraries is not so good, but I don't think automatic rejection marking is going to solve it -- so far it seems to be making some things worse :(
The easiest way out of this one is for promise users to settle on a flag, e.g. SomeError.prototype.isPromiseRejection = true, and for error() to all errors that have it. Then people can use create-error to make rejections
Automatic rejection marking should be possible, yes -- but opt-in, maybe via a method that converts the library in a similar manner that .promisify does that for callbacks.
What do you think?