Desugaring mental model
An async function always returns a Promise. Code before the first await runs synchronously when you call it. Each await waits for a thenable, then continues the function body in a later turn — equivalent to chaining .then.
async function load() {
console.log("start");
const v = await Promise.resolve(42);
console.log(v);
return v;
}
load();
console.log("after call");
// start → after call → 42Open in VisualizerResumption is a microtask
When the awaited Promise fulfills, the continuation is scheduled as a Promise reaction (microtask). That is why await still beats a zero-delay timer scheduled in the same synchronous turn:
async function f() {
await null;
console.log("awaited");
}
setTimeout(() => console.log("timeout"), 0);
f();
// awaited → timeoutOpen in VisualizerRejection and try/catch
Rejected awaits throw into the async function. try/catch around await maps to .catch on the underlying Promise chain. Unhandled rejections still surface if you neither catch nor attach handlers to the returned Promise.
async function boom() {
try {
await Promise.reject(new Error("nope"));
} catch (e) {
console.log("caught");
}
}
boom();Open in VisualizerWhen not to await everything
Sequential awaits on independent I/O serialize work. Prefer Promise.all (or allSettled) when requests do not depend on each other. Also avoid awaiting inside tight CPU loops — you pay microtask overhead without I/O benefit.