content icon indicating copy to clipboard operation
content copied to clipboard

Correction: At most one task is completed before microtasks are run

Open vinhill opened this issue 1 year ago • 0 comments

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/HTML_DOM_API/Microtask_guide/In_depth

What specific section or headline is this issue about?

Event loops

What information was incorrect, unhelpful, or incomplete?

Each agent is driven by an event loop, which collects any user and other events, enqueuing tasks to handle each callback. It then runs any pending JavaScript tasks, then any pending microtasks, then performs any needed rendering and painting before looping again to check for pending tasks.

What did you expect to see?

I do not know what would be correct, but I expect something like

... It then runs at most one pending JavaScript task ...

Do you have any supporting links, references, or citations?

This is at least in conflict with the microtask guide

First, each time a task exits, the event loop checks to see if the task is returning control to other JavaScript code. If not, it runs all of the microtasks in the microtask queue.

Also, a code example in Firefox:

setTimeout(() => {
  console.log("a");
  queueMicrotask(() => console.log("c"))
})
setTimeout(() => console.log("b"))

result: "a c b"

Do you have anything more you want to share?

No response

MDN metadata

Page report details
  • Folder: en-us/web/api/html_dom_api/microtask_guide/in_depth
  • MDN URL: https://developer.mozilla.org/en-US/docs/Web/API/HTML_DOM_API/Microtask_guide/In_depth
  • GitHub URL: https://github.com/mdn/content/blob/main/files/en-us/web/api/html_dom_api/microtask_guide/in_depth/index.md
  • Last commit: https://github.com/mdn/content/commit/56c76424a5edb45f6716ac4ee48861dac8e7ae38
  • Document last modified: 2023-08-04T07:12:32.000Z

vinhill avatar Apr 30 '24 09:04 vinhill