Promise.all Threw Away 9 Good Results Because 1 Call Failed
Promise.all on 10 calls with 1 failure returned 0 results, not the 9 that actually succeeded Promise.all rejected at 19.6ms, abandoning three calls still running at the 300ms mark Promise.allSettled kept all 9 good resul
Promise.all on 10 calls with 1 failure returned 0 results, not the 9 that actually succeeded
Promise.all rejected at 19.6ms, abandoning three calls still running at the 300ms mark
Promise.allSettled kept all 9 good results and waited the full 300ms for the slow ones
I now default to allSettled for any fan-out and reserve Promise.all for one true all-or-nothing step
I kept hearing that Promise.all throws away every good result the moment one call in the batch fails, even the ones that already succeeded, and I didn't quite believe it until I wrote ten calls in Node, failed one of them on purpose, and watched the other nine disappear.
Here's the run that proved it, the timing nobody mentions when they explain the difference, and the one line that fixed the batch job.
The Run That Lost 9 Good Results
I built ten fake calls, each resolving after a short random delay, and made call number 7 reject instead. Then I ran the batch two ways.
const calls = Array.from({ length: 10 }, (_, i) => fakeCall(i, i === 7));
try {
const results = await Promise.all(calls);
console.log('succeeded:', results.length);
} catch (e) {
console.log('Promise.all threw:', e.message);
}
The output was Promise.all threw: call 7 failed: upstream timeout. No results array, no partial list, nothing. The other nine calls had already resolved successfully by the time the catch block ran, and their answers were simply gone, because Promise.all only ever gives you one thing: every result if all of them succeed, or the first rejection if any of them doesn't. There's no middle setting.
Swap in Promise.allSettled with the identical ten calls:
const results = await Promise.allSettled(calls);
const fulfilled = results.filter(r => r.status === 'fulfilled');
const rejected = results.filter(r => r.status === 'rejected');
console.log(`${fulfilled.length} fulfilled, ${rejected.length} rejected`);
Output: 9 fulfilled, 1 rejected, with the rejected entry carrying the exact reason, call 7 failed: upstream timeout. Same ten calls, same one failure, completely different outcome, because allSettled never short-circuits. It waits for every promise to finish one way or the other and hands back a full report instead of a single verdict.
I'd read the one-line description of both functions a dozen times before this, "all rejects if any rejects, allSettled never rejects." I'd nodded along without registering what "rejects" actually throws away. It's not just an error. It's every successful result that happened to be sitting next to the failure.
Both functions take the same input, an array of promises, and that's part of why it's easy to swap one for the other without noticing the contract changed underneath the call site. The function signature doesn't warn you. Only the shape of what comes back does, an array of plain values from all, or an array of {status, value} or {status, reason} objects from allSettled. Any code written against all's shape breaks silently if you swap in allSettled without updating how the results get read, because results[3].someField on a settled array reads a status wrapper, not the value it used to.
The Timing Nobody Mentions
The result difference gets most of the attention, but the timing difference is the one that bit my batch job harder. I ran a second test: four calls, three of them take 300ms, one of them fails fast at 20ms.
const start = process.hrtime.bigint();
try {
await Promise.all(makeCalls());
} catch (e) {
const ms = Number(process.hrtime.bigint() - start) / 1e6;
console.log(`rejected after ${ms.toFixed(1)}ms`);
}
Promise.all rejected after 19.6ms, the moment the fast failure landed. The three 300ms calls were still in flight when the catch block ran. They weren't cancelled, since nothing in the language cancels a promise once it's created, so they kept running to completion somewhere in the background with no code left waiting on them. Their results, and any side effect they were supposed to trigger on completion, just happened in a function that had already moved on.
Promise.allSettled on the same four calls took 300.7ms, because it has to wait for the slowest one no matter how fast the others resolve or reject. That's the tradeoff in one sentence: all fails fast and silently abandons whatever was still running, allSettled always waits for the stragglers but never abandons anything.
Translate that into a real fan-out job: nine rows hitting a slow downstream API and one row failing validation before it even reaches the network. With Promise.all, that one fast, cheap failure throws away nine successful, expensive API calls, because the rejection lands long before the others finish. Nobody writing that code intends that outcome. It's just what all does by construction, and the behavior stays invisible in testing for as long as your test data happens to all succeed or all fail together, which is an easy thing to not notice until a single bad row shows up for real.
What allSettled Costs You
Switching isn't free, and the cost is exactly why Promise.all still exists as the default most people reach for first. allSettled never rejects on its own, so every call site has to check each result's status itself instead of relying on a single try/catch around the whole batch. Skip that check and a silently failed item looks identical to one that never ran, since both just aren't in your "success" list unless you went looking.
A rewrite that handles the fan-out job above without throwing away the good results looks like this:
const results = await Promise.allSettled(rows.map(processRow));
const failures = results
.map((r, i) => ({ r, row: rows[i] }))
.filter(x => x.r.status === 'rejected');
if (failures.length) {
for (const f of failures) log.warn('row failed', f.row.id, f.r.reason.message);
}
const succeeded = results.filter(r => r.status === 'fulfilled').length;
That's maybe six more lines than the try/catch version, and all six are there because the job now has to decide what "partial success" means instead of getting that decision made for it. For a batch of independent rows, a few bad ones shouldn't sink the rest. For a bank transfer split across three ledger writes, one failure should absolutely stop the whole thing, which is exactly the case where Promise.all's fail-fast behavior is the correct one, not a gotcha to route around.
There's a middle case worth naming too: a batch that should keep running, but only up to a point. If a hundred rows go through allSettled and ninety of them fail, that's not nine good results slipping past a bad one anymore, that's a downstream dependency that's actually down, and silently reporting "10 succeeded" without raising an alarm is its own kind of bug. The fix is one more check on top of the result-filtering code above: once the failure count passes some fraction of the batch, log it as an error instead of a warning, so a real outage still gets noticed instead of hiding inside a success count that technically isn't zero.
Where This Pattern Hides in Real Code
Once I knew what to look for, I found the same shape in places I wasn't expecting. A page that loads a user's profile, their recent orders and their notification settings with three parallel calls is a fan-out, and if the notification settings endpoint has a bad day, Promise.all throws away the profile and orders that already loaded fine, even though the page could have rendered both of those sections and shown an error only where it belongs. A function that sends the same email to twenty recipients through Promise.all fails the entire send the moment one address bounces, so nineteen people who should have gotten the email don't, because of the twentieth.
Promise.any and Promise.race are worth knowing about here too, mostly so you don't reach for them by accident. Promise.any resolves as soon as the first promise succeeds and only rejects if every single one fails, which is the right tool for "ask three mirrors for the same file, take whichever answers first." Promise.race settles on whichever promise finishes first, success or failure, which is what you want for a timeout wrapper: race the real call against a timer promise that rejects after some number of milliseconds, and whichever one lands first wins. Neither one is a drop-in replacement for all or allSettled, because neither is answering "how did my batch of independent work go." They're answering "which one finished first," which is a different question that happens to use the same Promise namespace.
The common thread across all four is that each one encodes a specific answer to "what do I do when more than one promise is in flight at once," and picking the wrong one doesn't throw an error that points at the mistake. It just quietly does the wrong thing with results you'll only notice are missing when someone asks where they went. I check this now whenever I see more than one await worth doing in parallel: what should happen to the good results if one call in the batch fails, and does the function I'm about to call actually implement that, or just the one I assumed it did.
Bottom Line
Promise.all is right when every call in the batch has to succeed for the result to mean anything, like three writes that form one transaction. Promise.allSettled is right the moment the calls are independent, which in my experience is most fan-out work: hitting the same API for ten different IDs, sending ten emails, fetching ten unrelated resources to render one page.
I default to allSettled now and only reach for all when I can say out loud why a single failure should void everything else. The nine results I lost weren't a bug in the function. Promise.all did exactly what its contract says. The bug was mine, for using an all-or-nothing tool on a job where nine failures out of ten mattering independently was always the real shape of the problem.
I ran a similar before-and-after comparison, real numbers instead of the usual hand-wave, in debounce vs throttle, where I counted every call, and the stale-response bug in that one shows up for the same reason this one does: async code doesn't wait around for you to reason about it correctly.
How many of your own Promise.all calls are sitting on a batch where one failure shouldn't cost you the other nine?
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.