The Runtime Theory

Async/Await Flow

What await really does: synchronous prefix, suspension, continuation capture, microtask resumption, and promise resolution.

The Runtime Theory Team07 stages

trace / request.md

SYNCHRONOUSPREFIXPROMISE CREATEDAWAIT SUSPENDSEXECUTIONAWAITEDPROMISE SETTLESCONTINUATIONQUEUEDMICROTASK RESUMESTHE FUNCTIONOUTER PROMISERESOLVES

readyThe async function is invoked and its body starts running synchronously on the current stack — the code before the first await executes exactly like a normal call.

await is a suspension, not a wait. This diagram follows an async function from call to completion: the synchronous prefix runs on the current stack, the first await captures the function's locals as a continuation and returns control to the caller, the awaited promise settles in some other task, and the continuation is enqueued as a microtask. When the current stack unwinds, the microtask runs and the function resumes after the await point — with its stack gone and its locals restored from the closure. The ordering matters because it explains both the guarantees and the surprises: microtasks beat timers, and stack traces across await are reconstructed, not real. The done stage shows the outer promise resolving with the final return value.