Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

JavaScript · Function

Promise.allSettled

Promise.allSettled() waits for every input promise to settle and fulfills with an input-ordered array describing each result. It reports both successes and failures instead of rejecting because one input failed.

Since
ES2020

How it works

Call Promise.allSettled with an iterable of values such as promises. It converts the values to promises, waits until every input is fulfilled or rejected, and fulfills with outcome records in input order. Each record identifies its state with status and carries either value or reason.

Syntax

Promise.allSettled(iterable)

Parameters

NameTypeDescription
iterableIterableAn iterable, such as an Array, whose elements may be promises, thenables, or non-promise values.

Returns

A Promise that fulfills with an array of outcome objects after all inputs settle. An empty iterable yields an already-fulfilled promise; a non-empty iterable with no pending promises fulfills asynchronously.

Key points

  • It is a static method on Promise and accepts an iterable rather than requiring an array.
  • The aggregate promise waits for every input to finish, including rejected inputs.
  • The fulfillment value is an array of outcome records, one corresponding to each input.
  • Result positions follow input order, not the order in which asynchronous operations finish.
  • Each outcome's status discriminates whether the operation succeeded or failed.
  • The value field exists for fulfilled outcomes, while rejected outcomes use reason instead.

Common mistakes

  • Even already-settled non-empty input produces its fulfillment asynchronously, so do not rely on immediate callback execution.

Example: Inspect every settled result

const results = await Promise.allSettled([
  fetch("/api/profile"),
  fetch("/api/recommendations"),
]);

for (const result of results) {
  if (result.status === "fulfilled") {
    console.log("Success:", result.value.status);
  } else {
    console.error("Failed:", result.reason);
  }
}

Runs independent requests together, then handles each outcome by checking its discriminating status field.

When to use it

Batch independent tasks

Run independent API requests or background operations while retaining both successful and failed outcomes.

Partial-success processing

Collect per-item results when some operations may fail without preventing the rest from completing.

Outcome auditing

Inspect every operation after a batch finishes for logging, metrics, or user-facing status reporting.

Interview questions

QWhat does Promise.allSettled() return?

It returns one promise that fulfills after every input has settled, whether the individual inputs fulfilled or rejected. Its result is an array ordered like the input, and each item reports status plus either value or reason.

Follow-up: How does it differ from Promise.all()? Promise.all() rejects as soon as an input rejects, whereas allSettled() waits for every input and reports all outcomes.

QWhat kinds of values can the iterable contain?

The iterable can contain promises, thenables, or ordinary values. Values are awaited through promise resolution, while non-thenables become fulfilled outcomes with their values.

Follow-up: What happens for an empty iterable? The returned promise is already fulfilled with an empty array.

QHow are fulfillment and rejection represented?

A fulfilled record has status set to "fulfilled" and a value property. A rejected record has status set to "rejected" and a reason property, so status should be checked before reading the corresponding field.

Follow-up: Does completion order affect the result order? No; records remain in the order of the original iterable.

  • Promise.all()
  • Promise.any()
  • Promise.race()
  • Promise

Source: Promise.allSettled() - JavaScript | MDN. Checked 2026-10-15.