Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confusion in event loop explanation of microtask queue #37510

Closed
iamharisai opened this issue Jan 6, 2025 · 2 comments
Closed

Confusion in event loop explanation of microtask queue #37510

iamharisai opened this issue Jan 6, 2025 · 2 comments
Labels
closed: question A user misinterpretation or support question. No action required. Content:WebAPI Web API docs

Comments

@iamharisai
Copy link

MDN URL

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

What specific section or headline is this issue about?

https://arc.net/l/quote/iuxvdrho

What information was incorrect, unhelpful, or incomplete?

https://arc.net/l/quote/iuxvdrho This paragraph portraits that the oldest runnable task in the task queue will be executed first and then the microtasks in microtask queue will be executed in a single iteration of the event loop. Which is not true, as the microtask queue has priority.

What did you expect to see?

The mentioning of in a single iteration of the event loop, the microtasks queue will be executed first untill it is empty, and then the next iteration will look for empty call stack, then empty microtaskqueue then the oldest runnable task in the task queue will be executed.

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

I am beginner in JS, so could be my fault to understand this.

Do you have anything more you want to share?

No response

MDN metadata

Page report details
@iamharisai iamharisai added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Jan 6, 2025
@github-actions github-actions bot added the Content:WebAPI Web API docs label Jan 6, 2025
@caugner caugner added the goal: clarity (Experimental label) Issues about unclear/confusing/inconcise content. label Jan 7, 2025
@Josh-Cena
Copy link
Member

Hi, our description is fully accurate. You can check https://html.spec.whatwg.org/multipage/webappapis.html#event-loop-processing-model. At every iteration of the event loop, we first process one task, then all microtasks, then paint the screen. Why? Because you can't have microtasks before you do at least one task. For example, the top-level code of <script> defines one task, and you have to execute that first.

@Josh-Cena Josh-Cena closed this as not planned Won't fix, can't repro, duplicate, stale Jan 29, 2025
@Josh-Cena Josh-Cena added closed: question A user misinterpretation or support question. No action required. and removed needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. goal: clarity (Experimental label) Issues about unclear/confusing/inconcise content. labels Jan 29, 2025
@iamharisai
Copy link
Author

Ah, you are right. Thank you so much for detailed explanation @Josh-Cena 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed: question A user misinterpretation or support question. No action required. Content:WebAPI Web API docs
Projects
None yet
Development

No branches or pull requests

3 participants