Skip to content

Conversation

foolip
Copy link
Collaborator

@foolip foolip commented Jun 10, 2025

No description provided.

@github-actions github-actions bot added the feature definition Creating or defining new features or groups of features. label Jun 10, 2025
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this perhaps be a feature called "Microtasks"?

Points in favor:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there are no other developer-exposed ways to use microtasks than via the queueMicroTask, then I agree with this suggestion. Let's re-id and re-name this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The concept of microtasks is much, much older than queueMicroTask(), so I think it would be confusing to name it just microtasks. IIRC, the concept was formalized when promises were introduced, but there were similar "delay this work until just before we return to the event loop" concepts around before that too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The counter argument I can see is that, before queueMicrotask, microtasks where only a concept, or a thing browsers did internally, rather than an API developers can use. If this description is correct, then I don't see much confusion in renaming the feature to microtasks, because that word never really matched with anything devs could do before.

Not a hill I will die on though. Happy to keep the proposed name too.

I remember doing setTimeout(1) years ago, is that how we used to queue microtasks before?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there are no other developer-exposed ways to use microtasks than via the queueMicroTask, then I agree with this suggestion. Let's re-id and re-name this.

@foolip
Copy link
Collaborator Author

foolip commented Aug 25, 2025

Coming back to this after the summer. Even though this is the only API surface explicitly about microtasks, microtasks were already there and possible to interact with. In fact queueMicrotask(fn) is equivalent to Promise.resolve().then(fn) and https://github.com/feross/queue-microtask is a polyfill using this.

I'm not opposed to a "Microtasks" feature as such, but its description would have explain microtasks and how to use them, which is more than queueMicrotask(). My preference is to just have an entry for it :)

@ddbeck ddbeck changed the title Add queueMicrotask() Add queueMicrotask() Aug 26, 2025
@ddbeck
Copy link
Collaborator

ddbeck commented Aug 26, 2025

OK, I am convinced that this should not be called "Microtasks" in general.

One thing that remains here that I only just noticed: what of the feature ID? #2866 is unresolved, so I don't know what we ought to do here. queuemicrotask or queue-microtask?

@foolip
Copy link
Collaborator Author

foolip commented Aug 27, 2025

I landed on the "queuemicrotask" side in #2866 so I'll rename this.

@foolip foolip requested a review from captainbrosset August 28, 2025 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature definition Creating or defining new features or groups of features.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants