See exactly why your async JavaScript runs in that order.
AsyncFlow parses your code with
acorn
(vendored, MIT) and runs it through a small purpose-built
interpreter that models the JavaScript event loop. It records an
immutable, step-by-step trace of everything the loop does
— call-stack pushes and pops, microtask and macrotask
enqueue/run, and every console.log. The player then
scrubs through that trace, so stepping backward is just replaying
a recorded step, never guessing.
Correctness is the whole point; a visualizer that lies is worse than none. The ordering semantics follow Jake Archibald's Tasks, microtasks, queues and schedules. Specifically:
setTimeout callback) runs, after which microtasks
drain again. Repeat.
await x always yields to the microtask queue —
even when x is already resolved (modern one-tick
await, matching current V8).
.then callbacks are enqueued as
microtasks, never run inline; returning a promise from
.then costs the extra adoption tick.
These behaviours are pinned by a test suite that asserts exact output ordering, verified against Node.js / V8.
console.log, literals and template
literals, variables, arithmetic/comparison/logical/unary
operators, arrays and indexing, if/else,
return, throw, new Promise,
.then/.catch/.finally,
Promise.resolve/reject/all/race/allSettled,
async/await, setTimeout,
queueMicrotask.
try/catch, object
literals, classes, destructuring, generators, real timer delays
(delays only decide ordering, not wall-clock), and I/O. Using
one shows a friendly "not supported yet" message with the line —
never a crash and never silently-wrong output.
setInterval is modelled as a single one-shot fire.