You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you try to do a all() around several promises and more than one of them get rejected, it fails with an "Error: This deferred has already been resolved". This seems to be due to the error callback being called immediately when the first rejection occurs, then again on the next rejected. It would perhaps be preferable to wait for all promises to either succeed or reject, and then call the appropriate callback? Or is there an obvious workaround/user error here? Example to reproduce:
var q = require('promised-io');
function fail(delay) {
var d = q.defer();
setTimeout(function () {
d.reject(new Error('foo'));
}, delay);
return d.promise;
}
q.all(fail(250), fail(500)).then(function () {
console.log("success");
}, function () {
console.log("error");
});
Result:
% node ntest.js
error
timers.js:96
if (!process.listeners('uncaughtException').length) throw e;
^
Error: This deferred has already been resolved
at notifyAll (/Users/jb/src/zpoller/node_modules/promised-io/promise.js:164:10)
at /Users/jb/src/zpoller/node_modules/promised-io/promise.js:229:3
at notify (/Users/jb/src/zpoller/node_modules/promised-io/promise.js:199:22)
at notifyAll (/Users/jb/src/zpoller/node_modules/promised-io/promise.js:179:5)
at [object Object].<anonymous> (/Users/jb/src/zpoller/node_modules/promised-io/promise.js:229:3)
at Object._onTimeout (/Users/jb/src/zpoller/ntest.js:6:11)
at Timer.ontimeout (timers.js:94:19)
The text was updated successfully, but these errors were encountered:
When you try to do a all() around several promises and more than one of them get rejected, it fails with an "Error: This deferred has already been resolved". This seems to be due to the error callback being called immediately when the first rejection occurs, then again on the next rejected. It would perhaps be preferable to wait for all promises to either succeed or reject, and then call the appropriate callback? Or is there an obvious workaround/user error here? Example to reproduce:
Result:
The text was updated successfully, but these errors were encountered: