Misleading information around await's interaction with microtask/task queues #24177
Labels
Content:JS
JavaScript docs
help wanted
If you know something about this topic, we would love your help!
MDN URL
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await
What specific section or headline is this issue about?
Control flow effects of await
What information was incorrect, unhelpful, or incomplete?
await
does not inherently push anything into the microtask queue, at least not unless the promise being awaited is already settled. The microtask queue is where promise tasks go after the promise is settled.await
simply pauses the function. The microtask of resuming the function is added to the queue when the promise ultimately settles.The "microtask queue" link to the EventLoop page also has no mention of the microtask queue.
This only happens if the promise is not already settled (or does not get settled within further execution of the current task). If settled, function continuation is added to the microtask queue and the current task of the event loop continues to run until its microtask queue is empty. You can create an event loop-blocking async function demonstrating this
Despite the use of await, the main thread is not freed to run the next task.
What did you expect to see?
A more accurate description await and its interactions with the task and microtask queues.
The microtask link is probably better directed to:https://developer.mozilla.org/en-US/docs/Web/API/HTML_DOM_API/Microtask_guide(see comment below)
Do you have any supporting links, references, or citations?
https://developer.mozilla.org/en-US/docs/Web/API/HTML_DOM_API/Microtask_guide
Do you have anything more you want to share?
No response
MDN metadata
Page report details
en-us/web/javascript/reference/operators/await
The text was updated successfully, but these errors were encountered: