Run this yourself. Every number and exit code in this article came from
async-await-benchmark/in the Coding Dunia code-examples repo.npm teston Node 22 or newer reprints them for your machine.
JavaScript async await lets you write asynchronous code that reads like synchronous code, without the nesting of .then() chains. An async function always returns a Promise, await pauses it until that Promise settles, and a normal try/catch handles failures. That's the part every guide covers. The part they skip is numeric: how much faster is parallel, what does one await cost, how many requests is too many, and which error patterns take the whole process down? I ran all four against a real HTTP server on Node 22 and wrote down what came back.
Async/await in one example
Here's the same fetch written both ways. Which one would you rather read at 2am during an incident?
// Promise chain
function getUser(id) {
return fetch(`/api/users/${id}`)
.then(res => res.json())
.then(user => fetch(`/api/orders/${user.id}`))
.then(res => res.json());
}
// Async/await - same logic, flat structure
async function getUser(id) {
const res = await fetch(`/api/users/${id}`);
const user = await res.json();
const orders = await fetch(`/api/orders/${user.id}`);
return orders.json();
}
Both do exactly the same thing. The second reads top to bottom. await works inside an async function or at the top level of an ES module, and it unwraps the Promise so user is the actual object, not a pending Promise.
A Promise is a JavaScript object representing the eventual result of an asynchronous operation, in one of three states: pending, fulfilled, or rejected. Top-level await lets you use await directly in an ES module without wrapping it in an async function, which is handy for one-off scripts and for module setup that depends on an async resource.
Promise.all against awaiting in a loop
Promise.all was about 17 times faster for 20 independent requests. I started a node:http server on 127.0.0.1 that answers every request after exactly 25 ms, then fetched 20 URLs from it with five strategies. Nine rounds each, interleaved so a busy moment on the machine hit every strategy. The machine was an Apple M1 with 8 cores, shared with other jobs the whole time, running Node 22.23.3. Two complete runs on 2026-10-16, run 1 and run 2 below, in milliseconds:
| Strategy | Measured | Ideal |
|---|---|---|
await inside a for loop | 556 / 564 | 500 |
Promise.all | 32.2 / 33.9 | 25 |
Promise.allSettled | 29.7 / 32.8 | 25 |
| pool of 5 | 116 / 118 | 100 |
| pool of 2 | 286 / 286 | 250 |
// Slow: each request waits for the previous one
for (let i = 0; i < 20; i++) { await fetch(url + i); }
// Fast: all 20 in flight at once
await Promise.all(Array.from({ length: 20 }, (_, i) => fetch(url + i)));
Promise.all finished 17.3x and 16.6x faster than the loop, against an ideal of 20x. The gap to the ideal is real. The loop paid about 3 ms per request on top of the server's 25 ms, which is the loopback round trip plus timer rounding, and Promise.all paid 7 to 9 ms in total. A real network adds its own latency to both, so the sequential penalty only grows.
The earlier version of this article said a dashboard dropped from 1.4 seconds to 380 ms. I can't reproduce a number like that from a source, so it's gone. What I can show is above, and it's tied to a script you can run.
Promise.allSettled cost the same as Promise.all here. The difference isn't speed, it's what happens on failure: all rejects at the first error and allSettled waits for everything and reports each outcome. When every input fails and you still want one error, Promise.any rejects with an AggregateError, and what its errors array survives is tested elsewhere.
Twenty requests to a 25 ms server took about 560 ms awaited in a loop and about 33 ms through Promise.all, a 17x difference that costs you one line of code.
Firing thousands of requests at once
At first it works. Then it doesn't. The usual advice is to cap concurrency, and I wanted to know where the cap belongs. Same server, same 25 ms delay, but now N requests at once through Promise.allSettled so failures are counted instead of thrown:
| Requests at once | Time, run 1 / run 2 | Failed, run 1 / run 2 |
|---|---|---|
| 10 | 28.6 / 30.7 ms | 0 / 0 |
| 100 | 44.8 / 40.3 ms | 0 / 0 |
| 1,000 | 262 / 284 ms | 0 / 0 |
| 2,000 | 1,181 / 394 ms | 0 / 0 |
| 5,000 | 4,046 / 7,868 ms | 0 / 665 |
| 5,000 through a pool of 50 | 3,187 / 3,371 ms | 0 / 0 |
The ideal for every row is 25 ms. At 100 requests the burst took 1.6x to 1.8x the ideal; at 1,000, roughly 10x. At 5,000, the burst had failures in six of the seven runs I made, between 185 and 893 requests, all with ETIMEDOUT. One run was clean. The pool of 50, which takes at most 50 requests at a time, finished the same 5,000 without a single failure in any of my runs, in 3.2 to 5 seconds.
Where the line falls depends on the machine, the load, the server and the network, and my server was on loopback, so don't copy my 2,000. The stable result is the shape: a burst is unreliable past some size and a pool isn't. Here's the pool I used, eight lines:
async function pool(limit, jobs) {
let next = 0;
const workers = Array.from({ length: limit }, async () => {
while (next < jobs.length) {
const job = jobs[next++];
await job();
}
});
await Promise.all(workers);
}
My old rule of thumb in this article was "reach for for...of first". The numbers don't support that. A loop was 17x slower than parallel at 20 requests. Reach for Promise.all when the set is small and known, a pool when it's large or unbounded, and a for...of only when order or a rate limit demands it.
The cost of one await
One await cost between 30 and 50 nanoseconds on a quiet core. I timed a million iterations of each shape, best of five, and the two quietest runs agreed:
| Case | Run 1 / run 2, ns per iteration |
|---|---|
| plain function call | 1.7 / 1.6 |
await a plain value | 50.4 / 42.8 |
await an async function call | 43.1 / 40.5 |
await Promise.resolve(x) | 44.8 / 42.0 |
the same loop written with .then() | 35.8 / 34.9 |
An await is 25 to 30 times a plain call, and a .then() loop is a bit cheaper than an await loop. In busier runs the same code measured up to 250 ns, which tells you how much to trust the absolute figures on a shared machine. The proportions held. Does it matter? A million awaits add about 45 ms. One 25 ms request is the cost of roughly half a million of them. Don't remove an await from code to save time. Do remove one when it serializes work that could overlap.
return await inside try/catch
A bare return promise skips your catch block. I asserted it:
const failing = async () => { await sleep(1); throw new Error('boom'); };
async function without() {
try { return failing(); } catch { /* never runs */ }
}
async function withAwait() {
try { return await failing(); } catch { /* runs */ }
}
On Node 22.23.3 the catch block ran in withAwait and did not run in without. The function hands the pending promise to its caller before it fails, and the rejection lands in the caller's lap.
Ticks tell the same story. I counted microtask ticks with a self-rescheduling microtask and compared each shape with an already-resolved promise. async () => await p cost 1 extra tick. async () => p, returning the promise without awaiting it, cost 2. Three awaits in a row cost 3. Promise.all of one promise and of three promises both cost 1, so waiting on three at once costs the same as waiting on one. That's a deterministic result, identical in every run, which the timing numbers above are not. Ticks don't paint anything, though: chunked work between resolved promises painted zero frames in a browser test.
Error patterns that crash the process
Three of the eight patterns I tried crashed it. Each case ran in its own child process on Node 22.23.3 with default flags, and I read the exit code:
| Pattern | Exit code | Crashed |
|---|---|---|
Start two promises, await them in order, the second one fails first, try/catch around both | 1 | yes |
The same two promises through Promise.all | 0 | no |
Two failures through Promise.all | 0 | no |
The same two promises through Promise.allSettled | 0 | no |
forEach(async) with a try/catch around it | 1 | yes |
for...of with await and a try/catch around it | 0 | no |
An async call with no await and no .catch() | 1 | yes |
That same call with a process.on('unhandledRejection') listener | 0 | no |
The first row is the one that surprised me. This code looks safe and isn't:
const a = okAfter(60, 'a');
const b = failAfter(10, 'fast-fail');
try {
await a;
await b;
} catch (e) {
console.log('caught', e.message);
}
b rejects at 10 ms while the code is still waiting for a. Nothing has attached a handler to b yet, so Node treats the rejection as unhandled and exits with code 1 before your catch can see anything. The try/catch is right there and it never fires. Put both in Promise.all and the same two promises exit with code 0 and print caught fast-fail.
Two more things I asserted. When two promises in a Promise.all both fail, the second error is swallowed without a crash. And Promise.all doesn't cancel anything: with one task failing at 10 ms and two more due at 40 ms, one task had finished when Promise.all rejected, and all three had finished 80 ms later. A rejected Promise.all leaves the other work running. If that work writes to a database, it still writes.
Error handling with try/catch
Use the try/catch you already know. One trap deserves a mention, and I checked it against my local server: fetch resolves on an HTTP 500. My server answered /fail with status 500, and the promise resolved with res.ok false.
async function loadDashboard(userId) {
try {
const res = await fetch(`/api/users/${userId}`);
if (!res.ok) {
throw new Error(`Request failed: ${res.status}`);
}
return await res.json();
} catch (err) {
console.error('Dashboard load failed:', err.message);
return null;
}
}
Only a network failure rejects, so you check res.ok yourself and throw. Note the return await on the last line of the try block: that's the form that keeps a failed res.json() inside your catch.
forEach doesn't wait
This looks right and is broken:
// BROKEN - forEach ignores the returned Promise
items.forEach(async (item) => {
await save(item);
});
console.log('done'); // logs first, saves are still running
I ran a three-item version and recorded the order: after forEach, item 1, item 2, item 3. Put a try/catch around it and an error inside the callback still crashes the process with code 1, because the callback's promise is nobody's business. The fix is for...of with await for sequential work, or await Promise.all(items.map(item => save(item))) for concurrent work.
When plain promises still fit
Do you actually need to pause? If you're composing with Promise.race, or kicking off fire-and-forget work, the raw API is cleaner. And in React, a client component can't await in its body; there you hand async work to useEffect, a data library, or the use() hook, which reads a promise created outside the render. Server Components are the exception: they can be async functions and await directly. Our React hooks best practices guide covers the cleanup patterns that keep async effects from leaking, and React data fetching with TanStack Query removes most of the manual async plumbing entirely.
Limits of these numbers
The exit codes, the tick counts and the order of events are deterministic, and they were the same in every run. The milliseconds aren't. One Mac with 8 cores shared with other jobs, a server on loopback, one Node version, one fetch implementation (undici 6.28.1). Timings differed by up to 20% between my two quietest runs and by several times in the busier ones, and the threshold where a burst starts failing moved from run to run. Treat 17x as "an order of magnitude" and treat "5,000 at once is too many" as a shape, not a limit.
Async/await adds no capability Promises didn't already have. It makes asynchronous code readable enough that ordinary developers stopped getting it wrong, mostly. Start independent work together, bound it when it's big, keep return await inside try, and never put an async callback in forEach.
Related Guides
- The Temporal API - once the awaited call resolves, Temporal is what makes the timestamps it hands back sane
- React Server Actions guide - the Actions API and useActionState build async transitions directly into the component model
- Node.js 20 to 24 migration - top-level await and the stable global fetch reshape how you write async server code
- Bun vs Node vs Deno 2026 - all three runtimes support top-level await, but their async and Promise handling differ in practice
- Three pillars of JavaScript bloat - why async libraries and polyfills sneak weight into your bundle