All topics
Asyncadvanced

Promise.all, allSettled, race, and any

Four static Promise combinators for running multiple promises concurrently, each with different rules for how they settle.

When you have multiple independent promises to run concurrently, Promise.all, Promise.allSettled, Promise.race, and Promise.any each combine them differently. Interviewers ask about all four together because the differences are precise and easy to mix up.

Promise.all is a relay race where the team's time only counts if everyone finishes. allSettled records every runner's result regardless. race is whoever crosses first. any only cares about first success, failing only if everyone trips.

Key Concepts

1
Promise.all resolves with an array of results once every promise has fulfilled, but rejects immediately with the first rejection reason if even one rejects, without waiting for the others. This fail-fast behavior suits cases where every result is required.
2
Promise.allSettled never short-circuits: it waits for every promise to settle, then resolves with an array of {status, value} or {status, reason} objects — right when partial success is acceptable.
{status, value}{status, reason}
3
Promise.race settles as soon as the first promise settles, fulfillment or rejection — commonly used for timeouts. Promise.any resolves with the first fulfillment, ignoring rejections, and only rejects if every promise rejects, with an AggregateError.