RubenVerborgh/AsyncIterator

Current task scheduler does not guarantee order

Closed this issue · 3 comments

The snippet at

// In the browser, alternate with setTimeout to avoid freezing
let i = 0;
return (task: Task) => {
if (++i < 100)
scheduleMicrotask(task);
else
setTimeout(task, i = 0);
}
}
can result in out-of-order execution when a microtask is scheduled before setTimeout has occurred.

@rubensworks Could you test if https://github.com/RubenVerborgh/AsyncIterator/tree/fix/task-order does not break anything? This should be the final guard before #29 can be released. (It's weird that we have not run into out-of-order bugs yet.)

Everything seems to work fine! (aside for #30 that is)

Thank you!