4 ms·
Edit: don't listen to me Note that `Promise.all` will reject immediately the moment any of it's promises reject. That means the other promises will also fail.
by lelandfe 4y ago
Edit: don't listen to me
Note that `Promise.all` will reject immediately the moment any of it's promises reject. That means the other promises will also fail.
You'll often want that behavior – just learned a new one this month, though: if you want to do concurrent promises that should be able to succeed/fail independently, use `Promise.allSettled`: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- remram 4y agoYou mean the other promises get canceled? I didn't even know you could cancel promises in JavaScript. edit: This is not accurate, Promise.all() will return when one fail, but in no way do "the other promises also fail". They are unaffected and you can wait for them again.
- lelandfe 4y agoCan you tell I'm still learning how asynchronous JS works :) You're completely right – the only thing changed is what `all` vs `allSettled` returns. Thanks for the check!