Himself
Promise.all() pretty simple. You are passing an array from promises. It returns a new promise that will be resolved when all promises in your array are resolved or will be rejected when any individual promise in the array is rejected.
var pAll = Promise.all([p1, p2, p3]); pAll.then(function(r) {
Some reasons Promise.all() may not work in your code:
- You do not pass an array of promises to it.
- Some of the promises in the array you pass never allow or reject, so
Promise.all() never solves / does not reject its promise. - You are not passing callbacks correctly to
.then() handlers, where you should be - You incorrectly return promises from internal functions so that they are distributed or properly linked
Your example:
Promise.all(bleh).then(console.log("We did it"));
Wrong. You must pass the function reference to .then() as follows:
Promise.all(bleh).then(function() { console.log("We did it") });
In your case, console.log() will execute immediately and not wait for promises permission.
In your verbose code, you are 100% sure that:
listing_helper.listingPriceUpdateRoutine(listing.asin)
returns a promise? And that this promise will be removed or rejected properly?
Note to readers . If you read all the comments, you will see that the actual OP problem was not with Promise.all() , but they received a speed limit for sending requests too quickly to the target host. Since this was supposed to propagate a query error that should have been easily visible, the OP also seems to have a problem with error handling or propagation, which is probably in code that has not been disclosed here.
source share