PREP WITH PROOF
Menu
PROGRAMMING & APIS / PRACTICAL GUIDE

Promise.all vs Promise.allSettled: Handle Partial Failures

Choose JavaScript promise aggregation by failure policy. Includes tested examples for result order, partial success, synchronous throws, cancellation and concurrency limits.

THE QUICK ANSWER

Use Promise.all when every result is required: one rejected input rejects the aggregate. Use Promise.allSettled when you need a record of every outcome before deciding what to keep. Both preserve input order, neither limits concurrency, and aggregate rejection does not cancel work already started.

Start with the result your caller can use

A dashboard loads an account profile, recent activity and a recommendation panel. If recommendations fail, the profile can still be useful. A different screen calculates a quote from inventory and pricing: showing either input alone may be misleading. Both screens launch independent asynchronous operations, but they need different contracts when an operation fails.

Choose that contract before choosing a promise method. Promise.all expresses an aggregate success requirement. Promise.allSettled collects outcomes so your code can make a later decision. Neither method knows which data is optional, whether a write is reversible, or how a user should experience an incomplete result. Those are application decisions.

This guide uses ordinary arrays of promises and standard built-in Promise methods. The examples run without a server or external requests. They demonstrate observable behavior rather than a performance benchmark. The controlled example and batch function below were exercised on Node.js 24.22.1; a separate browser or production API integration is outside that test.

RequirementChooseCaller receives
Every value is requiredPromise.allValues in input order, or one rejection
Inspect every independent outcomePromise.allSettledOrdered fulfilled/rejected records
One component has an approved fallbackExplicit catch on that component, then aggregateA documented default or fallback value
Large input with a service limitBounded scheduler plus a failure policyControlled in-flight work, with deliberate outcome handling

Promise.all gives one aggregate success or failure

For a required group, await the combined promise inside the error boundary responsible for the screen or operation. On success, destructure results in the same order as the input. A quicker second operation does not move its value into the first position. Use descriptive variable names so positional mapping stays reviewable.

When an input rejects, the combined promise rejects without waiting for all remaining inputs to finish. The rejection reason is the first rejection observed by the aggregate; it is not necessarily the first item in the array. You do not receive a partially filled success array from that await. If every individual outcome matters for diagnostics or recovery, keep that information explicitly or collect it with allSettled.

An early rejection is not a transaction rollback. A request may already have reached a server and another operation may still be running. Promise.all attaches handlers to its inputs, but your own aggregate still needs handling. Await it in try/catch or return it to a caller that handles rejection; dropping the returned promise loses the application’s error boundary.

Source: ECMAScript: Promise.all algorithm ↗

Prove order and continued work without racing timers

Save this as promises-demo.mjs and run node promises-demo.mjs. Manually controlled promises let the example settle the second item first, then reject a different group while a sibling remains unfinished. This avoids making assertions about milliseconds, CPU scheduling or network speed.

The first assertion establishes result order. The next assertions establish that the failed aggregate has settled while its sibling has not, and that the sibling can still complete afterward. Nothing in this example aborts an operation. The final allSettled call inspects the same promises after both have settled; it does not rerun their work.

import assert from 'node:assert/strict';

function deferred() {
  let resolve, reject;
  const promise = new Promise((yes, no) => {
    resolve = yes;
    reject = no;
  });
  return { promise, resolve, reject };
}

const first = deferred();
const second = deferred();
const ordered = Promise.all([first.promise, second.promise]);
second.resolve('second');
first.resolve('first');
assert.deepEqual(await ordered, ['first', 'second']);

const failed = deferred();
const sibling = deferred();
let siblingFinished = false;
const siblingWork = sibling.promise.then(value => {
  siblingFinished = true;
  return value;
});
const aggregate = Promise.all([failed.promise, siblingWork]);
const handled = aggregate.catch(error => error.message);
failed.reject(new Error('inventory unavailable'));
assert.equal(await handled, 'inventory unavailable');
assert.equal(siblingFinished, false);
sibling.resolve('pricing completed');
assert.equal(await siblingWork, 'pricing completed');

const outcomes = await Promise.allSettled([
  failed.promise, siblingWork
]);
assert.equal(outcomes[0].status, 'rejected');
assert.equal(outcomes[1].status, 'fulfilled');
assert.equal(outcomes[1].value, 'pricing completed');
console.log('Order, early rejection and continued work verified.');

Keep identity beside allSettled outcomes

For independent batch items, inspect status before reading value or reason. A fulfilled outcome has a value; a rejected one has a reason. Do not test value truthiness to decide success: false, zero, an empty string and undefined can all be legitimate fulfilled values. Conversely, a rejection reason can be a string or another value rather than an Error instance.

Keep a stable item ID beside each outcome. Filtering successful results and then pairing them with the original ID array shifts positions after the first failure. Instead, associate each outcome with its original index first. You can then create separate success and failure lists without assigning the wrong response to an item.

The function below accepts a worker so its behavior can be tested with local data. Wrapping each invocation in Promise.resolve().then also converts a synchronous worker throw into an item rejection. Without that wrapper, a non-async function that throws during items.map can interrupt array construction before allSettled is even called. This is a small batch example, not a concurrency-limited queue.

After collecting the report, make an explicit decision: render successful cards, display a partial-results notice, or reject the entire higher-level operation because a required item failed. A fulfilled allSettled aggregate does not mean every job succeeded. Store useful failure categories internally and show users a safe explanation rather than blindly printing raw exception details.

async function inspectBatch(items, worker) {
  const outcomes = await Promise.allSettled(
    items.map(item => Promise.resolve().then(() => worker(item)))
  );
  return outcomes.map((outcome, index) => ({
    id: items[index].id,
    ...outcome
  }));
}

const report = await inspectBatch(
  [{ id: 'profile' }, { id: 'recommendations' }, { id: 'count' }],
  item => {
    if (item.id === 'recommendations') throw new Error('offline');
    return item.id === 'count' ? 0 : { name: 'Example' };
  }
);
const successes = report.filter(row => row.status === 'fulfilled');
const failures = report.filter(row => row.status === 'rejected');
console.log(successes.map(row => row.id)); // ['profile', 'count']
console.log(failures.map(row => row.id));  // ['recommendations']

Source: MDN: Promise.allSettled outcomes ↗

Aggregation does not start functions or create a limit

Promise.all([loadProfile, loadActivity]) receives two function values; it does not invoke them. Call the functions when you mean to create their operations. Similarly, passing an array produced by an async map gives an array of promises, while awaiting that array directly does not wait for its members. Aggregate the promises, or iterate deliberately.

If you write await loadProfile() followed by await loadActivity(), the second invocation happens after the first await finishes. For independent work, create both operations before awaiting the group. If activity needs a profile identifier from the first response, the dependency is real: do not force concurrency merely to use Promise.all.

Calling items.map(worker) over ten thousand items may start ten thousand operations before any aggregation occurs. Neither all nor allSettled provides a concurrency setting, rate limit or memory bound. Use a scheduler that starts only a chosen number of workers at once, and test that the active count never exceeds that limit. A rate limit also needs time-based policy; a simultaneous-request cap alone is not requests per second.

Promises coordinate eventual results; they do not automatically move CPU-heavy JavaScript onto another thread. If one worker performs a long synchronous calculation, it can still block other JavaScript on that thread. Measure the actual bottleneck before describing a change as parallel execution or promising a speedup.

Source: MDN: Promise.all behavior and examples ↗

Treat HTTP status, parsing and cancellation separately

For fetch-based work, a received HTTP error response such as 404 or 500 does not by itself reject the fetch promise. Your worker must check the response status, usually response.ok, and throw or return a typed failure according to the application contract. Otherwise allSettled may correctly report fulfilled even though your business operation considers the response unsuccessful.

Include the body read and parsing inside the worker promise if they are part of completion. Returning a Response and parsing its JSON later moves parsing errors outside the aggregate you thought was monitoring the operation. A useful boundary is an async fetchJson worker that awaits fetch, checks ok, then returns response.json(); the async return adopts the parsing promise.

Cancellation requires support from the underlying operation. A shared AbortController signal can be passed to related fetch calls; a catch around the required group can request controller.abort() before rethrowing the original error. This is an explicit group policy, not behavior supplied by Promise.all. Some siblings may already have completed, and aborting a client request cannot guarantee that a server-side write did not happen.

Likewise, racing an operation against a timeout promise changes which result the caller observes but does not inherently stop the losing operation. Use the client’s supported signal or deadline mechanism and a cleanup policy. allSettled can remain pending indefinitely when an input never settles; waiting for every result needs a deliberate time bound in real integrations.

Source: WHATWG Fetch Standard: fetch method ↗

Debug the outcome contract before adding retries

Both methods fulfill with an empty array for empty input when called normally on Promise. That may be a valid no-work result, or it may reveal an upstream selection bug. Validate the intended batch size when an empty report would mislead the caller. Reactions registered with then or await still run asynchronously; do not use these methods as synchronous branching shortcuts.

For normal iterable input, individual rejected promises become rejected records under allSettled. The method can still return a rejected aggregate when setup fails, for example when the supplied value is not iterable. Avoid the blanket claim that allSettled can never reject, and preserve an outer error boundary for setup and later report processing.

A catch that returns a fallback converts that branch into fulfillment. That can be appropriate for an optional recommendation panel, but returning an empty array for every error can conceal outages and turn a required failure into plausible-looking success. Record the fallback decision and distinguish a genuine empty result from unavailable data.

Retry only failures whose operation is safe to repeat, and apply retries at the intended layer. Rerunning the entire batch after one item fails can duplicate successful writes. Prefer targeted retry of eligible failed IDs with a total deadline and an explicit attempt policy. Our related HTTP retry guide explains time budgets and idempotency; the promise combinator itself supplies neither.

The practical choice is a failure contract your caller can explain. Use all for a required group, use allSettled to retain independent outcomes, and keep identity, limits, cancellation and recovery visible in the surrounding code. A few controlled rejection tests usually reveal more than a happy-path demonstration with two fast requests.

Source: ECMAScript: Promise.allSettled algorithm ↗

KEEP THESE THREE THINGS

Your next steps

  1. Choose the failure policy before the combinator: required group, independent outcomes, or explicit optional fallback.
  2. Start independent work deliberately, keep IDs beside outcomes, and distinguish HTTP errors from rejected fetch promises.
  3. Add supported cancellation, deadlines and concurrency limits separately; test failure and partial-success paths.

Sources & official resources

Linked resources checked on 2026-10-24. Technical behavior and provider guidance can change; check the documentation for the version you use.

About this guide and its recommendations

Published by Prep With Proof with AI-assisted drafting. Study routines and examples are editorial suggestions, not official exam instructions or claims of a learner's personal results. Cited provider facts are linked; ownership of recommended Prep With Proof products is disclosed. No competitor endorsement or guaranteed certification outcome is implied.

Suggest a correction →