Promise.all vs race vs allSettled vs any in JS

JavaScript provides four static concurrency methods—known as Promise combinators—to manage multiple asynchronous operations running in parallel: Promise.all, Promise.race, Promise.allSettled, and Promise.any. While all four accept an iterable of Promises, they differ significantly in their completion criteria, short-circuiting behaviors, and how they handle fulfillments versus rejections.

Promise.all

Promise.all accepts an iterable of promises and fulfills only when all input promises have fulfilled. It returns a single promise that resolves to an array of the fulfilled values in the exact order of the original input.

Promise.allSettled

Promise.allSettled waits until every input promise has settled, meaning each has either fulfilled or rejected. It never short-circuits on a rejection.

Promise.race

Promise.race settles as soon as the first promise in the iterable settles, whether that first outcome is a fulfillment or a rejection.

Promise.any

Promise.any waits for the first fulfilled promise. Unlike Promise.race, it ignores rejections as long as there is at least one promise that might still fulfill.

Summary Comparison

Method Fulfills When Rejects When Short-Circuits On
Promise.all All promises fulfill Any promise rejects First rejection
Promise.allSettled All promises settle Never rejects None (waits for all)
Promise.race First promise fulfills First promise rejects First settlement (fulfillment or rejection)
Promise.any First promise fulfills All promises reject First fulfillment