Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober 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 Scan×
Skip to content
World desk2 min

Handle Partial Failures in Optional Widgets with Promise.allSettled()

Use Promise.allSettled() to collect each optional widget's success or failure, then render available content and choose a fallback for failed loads.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Promise.allSettled() when optional widgets load independently and the page should keep usable results even if one or more loads fail. It waits for every input to settle, then gives you a success or failure record for each one so your code can render each widget accordingly.

How Promise.allSettled() handles widget loads

Promise.allSettled(iterable) returns a promise that fulfills after every input promise has either fulfilled or rejected. The resulting array stays in the same order as the inputs, and each entry reports one outcome:

As an Amazon Associate I earn from qualifying purchases.

  • { status: "fulfilled", value: ... } for a fulfilled promise.
  • { status: "rejected", reason: ... } for a rejected promise.

This lets a dashboard, for example, show weather and news even if recommendations fail. The method only collects outcomes; your application decides whether to show a fallback, omit the failed widget, or offer a retry. It does not render widgets, retry requests, cancel slow work, or impose a timeout.

Free tools Windows power users keep installed

One-click scans. No signup required.

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

Render each widget from its own outcome

Keep a reliable link between each request and its widget. Since outcomes match input order, index-based mapping works as long as the inputs and their associated keys remain aligned. Pairing a key with each load makes that relationship easier to maintain:

const widgets = [
  { key: "weather", load: loadWeather() },
  { key: "news", load: loadNews() },
  { key: "recommendations", load: loadRecommendations() },
];

const outcomes = await Promise.allSettled(widgets.map(({ load }) => load));

for (const [index, outcome] of outcomes.entries()) {
  const key = widgets[index].key;

  if (outcome.status === "fulfilled") {
    renderWidget(key, outcome.value);
  } else {
    renderWidgetFallback(key, outcome.reason);
  }
}

Check status before reading value or reason; those fields belong to different outcome types. Adapt the fallback to your interface, and avoid displaying raw rejection details to users if they could reveal internal or unsuitable information. Send diagnostic details through your application’s normal logging or error-reporting path.

When to choose allSettled() or all()

Method Combined promise behavior Use it when
Promise.allSettled() Fulfills after every input settles and returns each outcome. Tasks are independent, partial results are useful, and the caller needs to handle each success or failure.
Promise.all() Fulfills when all inputs fulfill; rejects when an input rejects. Tasks depend on one another or any failure should reject the combined operation.

Do not use allSettled() simply to suppress errors from required or dependent data. Choose the method that reflects what the application can do with a partial result.

Account for the wait-for-all trade-off

The combined continuation from allSettled() cannot run until the slowest input settles. That is useful when a single rendering pass needs a complete inventory of successes and failures, but it can delay display of widgets that finished earlier. If widgets should appear as soon as their own requests complete, handle each completion separately rather than waiting for the aggregate result.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Check runtime compatibility

MDN marks Promise.allSettled() as widely available across browsers since July 2020. Confirm support against the browsers and runtimes your project actually targets, especially if it must run in older or constrained environments. The method is also specified in the ECMAScript 2025 language specification.

Rank #4
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers

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
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

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.