The key output order is timer -> promise. Timers and microtasks are different queues, and test helpers may advance only one of them.
A production symptom appears first: flaky tests, stale state, slow UI, late cleanup, or growing memory. This is common in Jest/Vitest tests for debounced inputs, retries, loading spinners, and async React components.
Writing flaky tests that assume all async work finished after advancing timers.
Fix the root scheduling, cleanup, or concurrency pattern instead of adding arbitrary waits.
try {
await operation();
} finally {
cleanup();
}The console lane proves the visible order: timer -> promise. The active line and queues show why source order changed.
Reproduce the symptom with a small test, apply the safer pattern, then verify the flaky, slow, or leaking behavior disappears.
Related cases
Continue with nearby confusion while the mental model is fresh.
React batched state log
This shows up in React forms, counters, analytics events, and logic that reads state immediately after updating it.
Effect cleanup race
This prevents wrong profile data, flickering search results, and stale route content in React apps.
Stale closure timeout
This affects delayed notifications, retry callbacks, telemetry, and timeout-based cleanup logic.
Was this clear?
This stays local for now. It helps you track where the product still needs sharper cases.