Promise.allSettled()
Added in ves2020 · Updated March 13, 2026 · Async APIs
promise async es2020 javascript
Promise.allSettled() is a static method that returns a promise that resolves after all given promises have either resolved or rejected. Unlike Promise.all(), it never rejects—instead, it waits for every promise to settle and provides the outcome of each one.
Syntax
Promise.allSettled(iterable)
Parameters
| Parameter | Type | Description |
|---|---|---|
iterable | Iterable | An iterable object (such as an Array) containing Promise objects or other values |
Return Value
Returns a Promise that:
- Resolves with an array of result objects after all input promises have settled
- Each result object has a
statusproperty:"fulfilled"or"rejected" - If the input contains non-promise values, they are treated as immediately fulfilled promises
Examples
Basic Usage
const promise1 = Promise.resolve(3);
const promise2 = new Promise((resolve, reject) => setTimeout(reject, 100, foo));
Promise.allSettled([promise1, promise2])
.then(results => {
console.log(results);
// [
// { status: fulfilled, value: 3 },
// { status: rejected, reason: foo }
// ]
});
Processing Mixed Results
async function fetchAllData(urls) {
const results = await Promise.allSettled(
urls.map(url => fetch(url).then(r => r.json()))
);
const successful = results
.filter(r => r.status === fulfilled)
.map(r => r.value);
const failed = results
.filter(r => r.status === rejected)
.map(r => r.reason);
return { successful, failed };
}
Handling Non-Promise Values
// Non-promise values are wrapped as fulfilled
const results = Promise.allSettled([1, 2, Promise.resolve(3)]);
results.then(console.log);
// [
// { status: fulfilled, value: 1 },
// { status: fulfilled, value: 2 },
// { status: fulfilled, value: 3 }
// ]
When to Use AllSettled
Use Promise.allSettled() when you need all results regardless of failures:
// BAD: Promise.all will reject on first failure
const results = await Promise.all(requests);
// GOOD: Promise.allSettled waits for all to complete
const results = await Promise.allSettled(requests);
results.forEach((result, index) => {
if (result.status === fulfilled) {
console.log(`Request ${index} succeeded:`, result.value);
} else {
console.log(`Request ${index} failed:`, result.reason);
}
});
Common Use Cases
- Loading multiple resources where partial failure is acceptable
- Collecting results from optional operations
- Implementing “at least try all” patterns where every attempt matters
Key Behaviors
- Never rejects: Always resolves, even if all input promises reject
- Waits for all: Only resolves after every promise has settled
- Preserves order: Results maintain the same order as the input iterable
- Result structure: Each result has
{ status: fulfilled, value: ... }or{ status: rejected, reason: ... }
See Also
Promise.all()— Waits for all promises to resolve (fails fast)Promise.race()— Resolves when the first promise settlesPromise.any()— Resolves when any promise fulfillsPromise— The Promise object overview