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

Early queueMicroTask() execution #855

Closed
aarong opened this issue Aug 18, 2020 · 0 comments
Closed

Early queueMicroTask() execution #855

aarong opened this issue Aug 18, 2020 · 0 comments

Comments

@aarong
Copy link

aarong commented Aug 18, 2020

The core-js polyfill implementation of queueMicroTask() always falls back on process.nextTick() in Node, which schedules execution ahead of promise resolve/reject microtasks. This is not the behavior that you get with Node's native queueMicroTask() function.

Consider the following:

Promise.resolve().then(() => {
  console.log("first");
})
queueMicrotask(() => {
  console.log("second");
})

Using the core-js polyfill you get "second/first", but using the Node 11+ native function you get "first/second".

This could be resolved using Promise.resolve().then(...) instead of process.nextTick(...). I realize there would be a performance penalty, but the alternative is running code in an unpredictable order, which can outright break things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant