October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

How to Handle Rejected Promises Returned by Promise.allSettled()

Promise.allSettled() fulfills with an outcome for every input. Check each status, handle rejected reasons safely, and decide whether partial success is acceptable.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

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

Promise.allSettled() does not throw just because one of its input promises rejects. Once every input has settled, it fulfills with an array of outcome objects. Check each object’s status: use value for fulfilled outcomes and reason for rejected ones, then decide what each failure means for your application.

Inspect each result by its status

A rejected input appears in the results as an object with status: "rejected" and a reason property. A fulfilled input has status: "fulfilled" and a value property. Branch before reading either field:

As an Amazon Associate I earn from qualifying purchases.

const results = await Promise.allSettled(tasks);

for (const [index, result] of results.entries()) {
  if (result.status === "fulfilled") {
    useValue(index, result.value);
  } else {
    reportFailure(index, result.reason);
  }
}

The aggregate promise normally fulfills after all inputs settle, including when some inputs reject. That means the await itself is not where you handle those individual rejections; handle them in the returned array.

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

Separate successful outcomes from failures

If your application needs to keep successes while reporting failures, collect both explicitly:

const results = await Promise.allSettled(requests);

const values = [];
const failures = [];

results.forEach((result, index) => {
  if (result.status === "fulfilled") {
    values.push({ index, value: result.value });
  } else {
    failures.push({ index, reason: result.reason });
  }
});

if (failures.length > 0) {
  console.error("Some requests failed", failures);
}

This example records failures; it does not decide whether they are harmless. Make that decision according to the task and product requirements rather than treating every rejection alike.

Keep outcomes associated with the right task

The returned array follows the order of the input promises, not the order in which they finish. Use that guarantee to associate results with labels or records:

const jobs = [
  { name: "profile", promise: loadProfile() },
  { name: "settings", promise: loadSettings() },
];

const outcomes = await Promise.allSettled(jobs.map((job) => job.promise));

const namedOutcomes = outcomes.map((outcome, index) => ({
  name: jobs[index].name,
  ...outcome,
}));

For dynamically created work, keep the input records or pair each promise with an identifier. Do not match failures to tasks based on which request completed first.

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

Choose what a rejection means for your application

Promise.allSettled() reports each outcome; it does not supply a retry, logging, or recovery policy. Decide what should happen after inspecting the results:

  • Independent optional work: Keep successful results and report or record failures. Continue only if partial success is acceptable for the feature.
  • Transient failure: Retry only if repeating the operation is safe and your application’s retry rules permit it. allSettled() does not retry automatically.
  • Required work: If any required operation fails, turn that outcome into an appropriate application-level error. A fulfilled aggregate promise does not prove every task succeeded.
  • User-facing operation: Give users useful context without exposing sensitive raw error details.

Use Promise.all() when every task must succeed

Choose the combinator based on the relationship between the tasks and what counts as a useful result:

Question Promise.allSettled() Promise.all()
What does the caller need? Every input’s outcome, including rejections. A combined result when every input fulfills.
What happens if an input rejects? The aggregate fulfills after all inputs settle; inspect the rejected entries. The aggregate rejects when an input rejects.
When does it fit? Independent tasks where partial success or a complete outcome report is useful. Tasks whose combined operation is useful only when all inputs succeed.

Promise.all() rejecting does not cancel the other work; inputs may continue executing. If cancellation is required, implement it separately rather than treating rejection as cancellation. For further detail, see MDN’s Promise.allSettled() reference and Promise.all() reference.

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

Format rejection reasons defensively

A rejected promise’s reason is the value used to reject it. It is often an Error, but JavaScript does not require that. Avoid assuming reason.message exists:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
function describeReason(reason) {
  if (reason instanceof Error) {
    return reason.message;
  }
  return String(reason);
}

const results = await Promise.allSettled(tasks);

for (const result of results) {
  if (result.status === "rejected") {
    console.error("Task failed:", describeReason(result.reason));
  }
}

Keep structured error handling appropriate to your application; converting a reason to text is useful for display or logging, but should not replace any domain-specific handling.

Do not use global rejection events as normal control flow

Global unhandled-rejection events are intended as fallback or debugging mechanisms for rejections without a handler. They are not a substitute for inspecting expected outcomes at the operation that calls Promise.allSettled(). MDN’s promise rejection events guide describes those events and their role.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.