
Best Way to Handle Multiple Promises in JavaScript (Promise.all vs Promise.allSettled)
Muhammad Kamran
If you write JavaScript long enough, you eventually run into situations where you must run several promises that don’t depend on each other. And many people — including me in the beginning — handle it like this:
const first = await firstPromise();
const second = await secondPromise();
This approach looks simple, but it’s slow. Both promises run one after the other, so the total time becomes:
t1 + t2
For example, if the first promise takes 1 second and the second takes 2 seconds, then your total wait time becomes:
1 + 2 = 3 seconds
This delay is unnecessary when the promises are independent.
Using Promise.all()
To solve this, JavaScript gives us Promise.all(). It runs all promises in parallel and waits for all of them to finish.
Your code becomes:
const [first, second] = await Promise.all([firstPromise(), secondPromise()]);
Now the total time is:
max(t1, t2) — not t1 + t2.
This is a major speed improvement when dealing with multiple asynchronous operations.
The Drawback of Promise.all
Promise.all() is fast, but it has one big issue:
If any promise fails, the entire Promise.all fails.
So even if 4 out of 5 promises succeed, you still get no results because one failed.
Promise.allSettled(): A Safer Alternative
When you want the result of every promise — including the ones that fail — Promise.allSettled() is a better option.
It returns an array of objects describing the outcome of each promise, like this:
[
{ status: "fulfilled", value: ... },
{ status: "rejected", reason: ... }
]This makes it a safer choice when you want full visibility and don’t want one failure to stop everything.
In short:
Promise.all → Fast, but fails completely if one fails.
Promise.allSettled → Slower than all, but always gives you the full picture.
Enjoyed this article?
Check out more of my content or get in touch if you'd like to work together on your next project.