Why the execution doesn't stop at await async/await JS?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
await does not freeze JavaScript the way a blocking sleep call would in some other languages. It pauses only the current async function and returns control to the event loop, which is why other code can keep running while that function waits for a promise to settle.
await Suspends One Function, Not the Whole Runtime
An async function is still just a function that returns a promise. When JavaScript reaches await, it splits the function into two phases:
- everything before the
awaitruns now - everything after the
awaitis scheduled to continue later
That is why this code logs in an order many beginners do not expect:
The output is:
Only demo() pauses. The surrounding script continues immediately.
The Event Loop Keeps the Program Moving
JavaScript is designed around an event loop. Network requests, timers, UI events, and promise continuations are all scheduled rather than handled with blocking waits.
So when you write:
JavaScript does not stop the browser tab or Node.js process. It says, in effect, "resume this async function after the promise resolves." While that promise is pending, the runtime can keep handling:
- other synchronous code that is already running
- timers
- user input
- other promise callbacks
That behavior is what keeps JavaScript environments responsive.
The Caller Must await Too If It Should Pause
Another common source of confusion is the calling function. If one async function calls another without awaiting it, the caller continues immediately.
Here, pageLogic() does not wait for fetchData() because the call is not awaited. If the caller should pause, the caller must also use await:
That is often the real explanation when someone says execution "doesn't stop" at await.
await Resumes in a Later Microtask
Even if the awaited promise is already resolved, the code after await does not continue in the same synchronous turn. The continuation is queued as a microtask.
The output is:
This is why await Promise.resolve() can still change execution order even though the promise is already fulfilled.
await Is Not a Global Pause Button
It helps to think of await as syntax for promise continuation, not as a stop-the-world instruction. If JavaScript blocked the entire runtime every time a network request or timer was awaited, browsers would freeze and servers would stop processing unrelated work.
That is exactly the problem async programming is trying to avoid.
Common Pitfalls
- Expecting
awaitto block all JavaScript instead of only the current async function. - Forgetting to
awaitthe async function call in the caller. - Reading log output as if promise continuations run in the same synchronous step.
- Using
awaitas though it were a sleep function that halts timers, UI events, and other callbacks. - Mixing synchronous mental models with event-loop behavior and then misdiagnosing correct async output as a bug.
Summary
- '
awaitpauses one async function, not the entire JavaScript runtime.' - Control returns to the event loop while the awaited promise is pending.
- Code outside the paused async function can keep running.
- If the caller should wait too, the caller must also use
await. - Promise continuations after
awaitrun later through JavaScript scheduling, even when the promise resolves quickly.

