Promise.all vs awaiting one by one

Read the explanation
What if

Each await finishes before the next line runs, so fetchData("b") starts only after a is done.

Predict first

Each fetchData waits 100 ms on the network. When does fetchData("b") start?

012345678910111213await fetchData("a")await fetchData("b")log a ba startsawait sleep(100)a endsb startsawait sleep(100)b ends

Tap any block to see what that thread is doing.

  • Waiting / parked
  • Running
  • Waiting on I/O
Step 1/4

The script awaits fetchData("a"). The next line doesn't run until it's done.

1const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));2 3async function fetchData(name) {4  console.log(`${name} starts`);5  await sleep(100); // a network call6  console.log(`${name} ends`);7  return name;8}9 10const a = await fetchData("a");11const b = await fetchData("b"); // starts only after a is done12console.log(a, b);

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

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