Explanation
What just happened
await fetchData("a") paused the script until a was done, so fetchData("b") was only called afterwards. Two independent calls ran in sequence: about 200 ms.
Try the what-if switch
- Promise.all: both calls start before anything is awaited. Each runs until its
await, so both waits overlap, andPromise.allresolves when the slower one does: about 100 ms. The results come back asa b, in the order given.
Why
An async function starts running the moment you call it. await is what makes the caller wait. Start everything first, then await them together.
Watch out
Promise.all fails fast. The first rejection rejects the whole thing, even though the other calls keep running in the background.
Common questions
Does await run promises in parallel?
No. await pauses until that promise settles before the next line runs, so two awaits in a row run one after the other.
Does Promise.all start the promises?
No. Calling an async function already starts it. Promise.all only waits for promises that are already running, and resolves with their results in the order you gave them.
What if one promise in Promise.all rejects?
Promise.all rejects right away, while the others keep running. Use Promise.allSettled to wait for every promise and get each one's result or error.
Verified: this timeline matches a real program, checked in CI on Node.js 22 and 24. How we verify. Unclear or wrong? Tell us