Using a specific order of attaching callbacks and resolving, one of the fulfillment handlers is called twice for the same promise.
Given the following NodeJS test program:
var Promise = require("bluebird");
var calls = 0;
var def = defer();
def.promise.then(function() {
console.log("1");
});
def.resolve();
def.promise.then(function() {
console.log("2");
calls++;
if (calls > 1) {
console.log("BLUEBIRD ERROR");
}
}).then(function() {
console.log("3");
});
function defer() {
var resolve, reject;
var promise = new Promise(function() {
resolve = arguments[0];
reject = arguments[1];
});
return {
resolve: resolve,
reject: reject,
promise: promise
};
}
I'd expect the output to be:
but this produces (using Bluebird 2.3.6):
Moving the .resolve() to before the first .then() makes the error disappear.
Using a specific order of attaching callbacks and resolving, one of the fulfillment handlers is called twice for the same promise.
Given the following NodeJS test program:
I'd expect the output to be:
but this produces (using Bluebird 2.3.6):
Moving the
.resolve()to before the first .then() makes the error disappear.