Promise.allSettled() in JavaScript
Promise.allSettled() is a static method that takes an array (or any other iterable) of promises and returns a new promise which fulfills once every passed promise has settled. It does not matter whether they succeeded (fulfilled) or failed (rejected): the method waits for all results, not only the successful ones.
Theory
TL;DR
Promise.allSettled(iterable)waits until all promises settle in any way.- The returned promise always becomes
fulfilled, it never rejects. - Its value is an array of
{status, value}or{status, reason}objects in input order. Promise.all(), by contrast, rejects on the very firstrejectand loses the remaining results.- Typical use: bulk data loading, parallel validation, batched request sending.
Quick example
const p1 = Promise.resolve('Success');
const p2 = Promise.reject('Error');
const p3 = Promise.resolve('One more');
Promise.allSettled([p1, p2, p3])
.then(results => console.log(results));Output:
[
{ status: "fulfilled", value: "Success" },
{ status: "rejected", reason: "Error" },
{ status: "fulfilled", value: "One more" }
]Every promise settled, the method did not "fall over", it returned a full summary: who succeeded and who failed.
Syntax:
Promise.allSettled(iterable)It returns a new promise that always ends up fulfilled and yields an array of objects with the results.
Shape of the result
Every element of the array is an object with the same set of fields:
| Field | When it appears | Value |
|---|---|---|
status | always | "fulfilled" or "rejected" |
value | if fulfilled | the promise result |
reason | if rejected | the failure reason |
The element order matches the order of the input promises, so a result is easy to map back onto the original list by index.
When to use Promise.allSettled()
- When it matters that you wait for all operations to finish, even if some of them fail.
- When you need to collect all results and errors together, in one report.
- For example, during bulk data loading, parallel validation, batched request sending, data cleanup and so on.
How it differs from Promise.all()
| Characteristic | Promise.all() | Promise.allSettled() |
|---|---|---|
| When it settles | Only if all promises succeed | When all promises settle (with any outcome) |
| What it returns | An array of value results | An array of {status, value/reason} objects |
| Behaviour on failure | Falls over on the first reject | Does not fall over, waits for everyone |
| State of the returned promise | Can be fulfilled or rejected | Always fulfilled |
| What it is used for | When everything has to succeed | When you need a report on all results |
A side by side example:
const a = Promise.resolve('A');
const b = Promise.reject('Error');
const c = Promise.resolve('C');
// Promise.all
Promise.all([a, b, c])
.then(console.log)
.catch(err => console.error('Promise.all:', err));
// Promise.allSettled
Promise.allSettled([a, b, c])
.then(console.log);Output:
Promise.all: Error
[
{ status: 'fulfilled', value: 'A' },
{ status: 'rejected', reason: 'Error' },
{ status: 'fulfilled', value: 'C' }
]Promise.all() stopped at the error, while Promise.allSettled() waited for everyone and returned the full report.
A practical example
Imagine you need to load data from several sources, and even if one of them is unavailable, you still need the rest:
const urls = ['/user', '/posts', '/comments'];
const requests = urls.map(url => fetch(url));
Promise.allSettled(requests)
.then(results => {
results.forEach((res, i) => {
if (res.status === 'fulfilled') {
console.log(`${urls[i]}: OK`);
} else {
console.warn(`${urls[i]}: failed`);
}
});
});This way you get a summary across all requests, even if one of them "fell over".
A simple analogy:
Imagine you ordered three deliveries:
Promise.all(): if even one delivery does not arrive, you get upset right away and stop waiting for the others.Promise.allSettled(): you wait for every courier, even if one shows up without a parcel, so that you know what happened to each delivery.
Summary table:
| Method | Behaviour on failure | Return value | When it settles |
|---|---|---|---|
Promise.all() | Falls over on the first reject | An array of successful values | When all succeed |
Promise.allSettled() | Never falls over | An array of {status, value/reason} | When all are settled |
Common mistakes
- Attaching
.catch()and expecting it to fire. The promise fromallSettled()does not reject, so failures must be looked up in the array elements whosestatus === 'rejected', otherwise a breakage goes unnoticed. - Mixing up
valueandreason. A rejected element has novalue, a fulfilled one has noreason: checkstatusfirst. - Thinking
allSettled()makes code resilient by itself. It only collects a report, the retry or degradation logic is still yours to write. - Forgetting about HTTP errors in
fetch.fetchrejects only on a network failure, so a 500 response lands infulfilledandres.okhas to be checked separately. - Reaching for
allSettled()where fail-fast is wanted. If the first failure makes the rest of the work pointless,Promise.all()finishes sooner and saves resources.
Short Answer
Interview readyA concise answer to help you respond confidently on this topic during an interview.