Promise.allSettled()
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 }
// ]
});
The results array tells you which promises succeeded and which failed, but a real application needs to separate them before acting on either group. The next example shows how to partition the outcomes into a successes list and a failures list so you can process each category independently---useful when you are fetching data from multiple APIs and want to render everything that loaded even if one endpoint is down.
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 };
}
The fetchAllData pattern works when every item in the iterable is a promise, but allSettled() also accepts plain values mixed in with promises. That behavior matters when you are building a result set from a combination of cached data and live fetches---you can pass everything in a single call without wrapping non-promise values yourself.
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 }
// ]
Whether you pass promises or plain values, allSettled() wraps every input as a settled promise. That uniform treatment means you can mix cached results with inflight requests without conditional logic. The trade-off is that you give up all()’s fast-fail behavior---each approach fits a different use case, and picking the right one depends on whether partial results are useful to your caller.
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);
}
});
Why allSettled() Matters
Promise.allSettled() is the right tool when every outcome matters, even if some operations fail. It lets you collect successes and failures in one pass without short-circuiting at the first rejection. That is ideal for batch jobs, dashboards, and parallel API calls where partial results are still useful.
Compared with Promise.all(), this method makes failure handling explicit. You are not choosing between success and failure up front. Instead, you are asking for the full report and deciding what to do with it after every promise has settled.
Reading the Results
Each result object has a small shape, but that shape is important: status tells you whether the promise fulfilled or rejected, and the related value or reason gives you the payload. That means downstream code can branch cleanly without wrapping every request in its own try/catch.
The order of the results always matches the input order, which makes it easy to line up responses with the requests that produced them. That consistency is useful when you need to build a table, summary, or retry list from mixed outcomes.
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
Promise.allSettled() never rejects---even if every input promise rejects, the wrapper resolves with an array of rejected outcomes. It only resolves after every promise has settled, and the result order matches the input iterable order exactly. Each element is an object with either { 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