Wait for all different promise to finish nodejs async await
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
If you need to wait for several asynchronous operations in Node.js, the usual tool is Promise.all. It does not matter that the promises come from different functions or resolve to different values. What matters is whether you want the group to fail fast on the first rejection or whether you want every result, including failures.
Use Promise.all for Concurrent Success-Or-Fail Groups
Promise.all takes an iterable of promises and resolves when all of them resolve. If any one rejects, the whole Promise.all rejects immediately.
These promises are different operations with different result shapes, and that is completely fine. Promise.all returns the results in the same order as the input array.
await Does Not Make Work Sequential by Itself
A common misunderstanding is that using await means everything is serialized. That is true only if you await each promise before creating the next one.
Sequential version:
Concurrent version:
The second version starts all three operations first and then waits for them together. That is usually what people mean by "wait for all promises to finish."
Use Promise.allSettled If You Need Every Outcome
If one failure should not cancel the whole group, use Promise.allSettled. It waits for every promise and gives you a status for each one.
This is useful for dashboards, batch jobs, or cleanup routines where partial success is still valuable.
Different Promise Types Are Not a Problem
The promises can come from HTTP calls, filesystem reads, database queries, timers, or any mix of async functions. They do not need to be "the same kind" of promise. Promises are a common protocol for eventual completion, so grouping them is normal.
What does matter is dependency. If one operation needs the output of another, then they cannot run concurrently. In that case, sequence is the correct model and Promise.all is the wrong tool.
Handle Errors Intentionally
Promise.all rejects on the first failure, but the other operations may still be running in the background because JavaScript promises are not magically cancelled. If cancellation matters, you need explicit cancellation support such as AbortController in APIs that support it.
That distinction is important in network-heavy code. "Rejected early" is not the same as "all other work stopped."
Common Pitfalls
- Awaiting each operation one by one when they could run concurrently.
- Assuming the promises must all return the same data type.
- Using
Promise.allwhen partial failure handling requiresPromise.allSettled. - Forgetting that a rejected
Promise.alldoes not automatically cancel the other tasks. - Running dependent operations concurrently when they actually require sequencing.
Summary
- Use
Promise.allto wait for multiple independent promises concurrently. - The promises may come from different functions and resolve to different types.
- Start the work first, then await the group if you want real concurrency.
- Use
Promise.allSettledwhen you need every result, including failures. - Choose concurrency only for independent operations, not dependent ones.

