Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Promise.allSettled(iterable) returns a Promise that fulfills with an array of outcome objects after every input has settled. Each object has a status of "fulfilled" or "rejected", plus either a value or a reason. The result array keeps the inputs’ original order, not the order in which they finish.

What does Promise.allSettled() return?

It returns a Promise whose fulfillment value is an array with one outcome object for each item in the input iterable. The aggregate Promise waits until every input has either fulfilled or rejected. An input rejection appears as a rejected outcome; it does not, by itself, make the aggregate Promise reject.

For example:

const results = await Promise.allSettled([
  Promise.resolve("profile"),
  Promise.reject(new Error("offline")),
]);

// [
//   { status: "fulfilled", value: "profile" },
//   { status: "rejected", reason: Error("offline") },
// ]

The two entries are outcome records, not a filtered list of successful values. Check each record’s status to determine which field to read.

What are the status values and fields?

Outcome Record shape Read this field
Fulfilled { status: "fulfilled", value } value
Rejected { status: "rejected", reason } reason

Branch on status before accessing the outcome-specific field:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
for (const result of results) {
  if (result.status === "fulfilled") {
    console.log("Value:", result.value);
  } else {
    console.error("Reason:", result.reason);
  }
}

The rejected record’s reason is the rejection value, which may be an Error object or another value.

Are results ordered by completion or input position?

They are ordered by input position. The entry at index 0 corresponds to the first item in the iterable, the entry at index 1 to the second, and so on—even if later inputs settle sooner. MDN describes the fulfillment value as an array whose entries appear in the order the promises were passed, regardless of completion order: MDN Web Docs: Promise.allSettled().

This makes index-based association reliable as long as you preserve the same order when pairing inputs and results. If you destructure the results, keep the variable order aligned with the input order.

Which inputs can you pass?

The argument is an iterable, commonly an array. Its elements do not have to be Promise objects: ordinary values are treated as fulfilled inputs, and thenables are assimilated through Promise resolution.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

An empty iterable produces a Promise that is already fulfilled with an empty array. With a non-empty iterable containing no pending promises, the aggregate Promise still fulfills asynchronously.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

When should you use allSettled() instead of all()?

Use Promise.allSettled() when you need to inspect every independent task’s outcome, including failures—for example, when gathering several optional results. Use Promise.all() when all inputs must succeed for the combined operation to succeed, or when an input rejection should reject the combined Promise. The ECMAScript specification defines the method’s behavior; see ECMA-262, 15th edition (June 2024).

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.