Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

Promise.allSettled — outcomes of all promises

Promise.allSettled accepts an iterable and returns a promise for an array of all element outcomes. It preserves input order and records both fulfilled values and rejection reasons.

Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support

Syntax

Promise.allSettled(iterable)

Promise.allSettled(iterable) is a static method available since ECMAScript 2020, not a separate Web API. It accepts a synchronous iterable, such as an array, and processes its elements according to Promise.resolve. Plain values are therefore valid inputs too. Support in the target browser must be checked separately; the Node version used in a repository does not prove it.

The returned promise fulfills with an array after every element settles, either by fulfillment or rejection. Results follow input order, not completion order. Each result is either { status: "fulfilled", value: ... } or { status: "rejected", reason: ... }. Check status before reading value or reason.

Unlike Promise.all, rejection of an individual element does not reject the aggregate promise. This does not mean the method can never reject it: invalid input, such as null, or an exception during iteration can cause rejection. If iteration completes without error but any element never settles, the aggregate promise remains pending.

For empty input, the returned promise is already fulfilled with [], but a callback passed to .then still runs asynchronously. The method neither cancels operations nor limits concurrency; it collects their outcomes.

Examples

const inputs = [Promise.resolve(10), Promise.reject("offline"), 30];

Promise.allSettled(inputs).then((results) => {
  console.log(JSON.stringify(results));
});

Result

[{"status":"fulfilled","value":10},{"status":"rejected","reason":"offline"},{"status":"fulfilled","value":30}]

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources