Run promises in parallel with Promise.all
Run promises in parallel with Promise.all in JavaScript, waiting for every result in order and failing fast on the first rejection. Node.js 24.
Awaiting in a loop runs one request at a time. Promise.all starts them together and returns the results in the order you gave.
const delay = (ms, v) => new Promise((r) => setTimeout(r, ms, v));
const started = Date.now();
const results = await Promise.all([delay(30, 'a'), delay(10, 'b'), delay(20, 'c')]);
const took = Date.now() - started;
console.log(results);
console.log(took < 55);[ 'a', 'b', 'c' ]
trueAll three timers start at once, so the total is about the longest delay, 30 ms, not the sum. The result array follows the order of the input, not the order of completion, so 'a' is first although it finished last. See Promise.all.
If any promise rejects, Promise.all rejects at once with that error, and the other results are lost, although the other operations keep running. Use Promise.allSettled when you need every outcome. With thousands of items, limit concurrency instead of starting all of them.