Each .then enqueues a microtask, and the queue is FIFO. The two first-level handlers (1 and 2) are queued first, so they run before any second-level handler is even scheduled. Only after 1 runs does 3 get queued, and after 2 runs does 4, producing the breadth-first order 1, 2, 3, 4.