2

I am following up after reading the post Difference between microtask and macrotask within an event loop context

The examples posted are

macrotasks: setTimeout, setInterval, setImmediate, requestAnimationFrame, I/O, UI rendering
microtasks: process.nextTick, Promises, Object.observe, MutationObserver

I am wondering where can I find the list of tasks added to the microtask queue in the official documents

Thanks

daydreamer
  • 87,243
  • 191
  • 450
  • 722

1 Answers1

-1

https://html.spec.whatwg.org/multipage/webappapis.html#perform-a-microtask-checkpoint

When a user agent is to perform a microtask checkpoint:

  1. If the event loop's performing a microtask checkpoint is true, then return.

  2. Set the event loop's performing a microtask checkpoint to true.

  3. While the event loop's microtask queue is not empty:

    3.1 Let oldestMicrotask be the result of dequeuing from the event loop's microtask queue.

    3.2 Set the event loop's currently running task to oldestMicrotask.

    3.3 Run oldestMicrotask.

    This might involve invoking scripted callbacks, which eventually calls the clean up after running script steps, which call this perform a microtask checkpoint algorithm again, which is why we use the performing a microtask checkpoint flag to avoid reentrancy.

    3.4 Set the event loop's currently running task back to null.

  4. For each environment settings object whose responsible event loop is this event loop, notify about rejected promises on that environment settings object.

  5. Cleanup Indexed Database transactions.

  6. Set the event loop's performing a microtask checkpoint to false.

When an algorithm running in parallel is to await a stable state, the user agent must queue a microtask that runs the following steps, and must then stop executing (execution of the algorithm resumes when the microtask is run, as described in the following steps):

Run the algorithm's synchronous section.

Resumes execution of the algorithm in parallel, if appropriate, as described in the algorithm's steps.

Steps in synchronous sections are marked with ⌛.