There is nothing in the microtask queue until promises resolve. Until then other tasks and (UI) events can be processed.
This is because the await
operator will make the corresponding async
function return immediately, allowing other JS code to execute. In your case the promise is returned by fetch
, which in practice will not resolve immediately. So there is nothing blocking here.
Then when the HTTP response makes the fetch
promise resolve, a microtask will indeed be created, which, when when executed will restore the corresponding async
function's execution context. Your example function has nothing else to do, so that is quickly done.
Note that it does not matter whether this function was originally called from within some other function: at this stage, only that particular function's execution context (in which an awaited promise resolved) is restored without any pre-existing callstack. So it does not return again to the wrapping function. That already happened in the first phase and will not happen again.
Then again there is free event processing until the next fetch
promise resolves. And so it continues.