Re:Async Iterators: These Promises Are Killing My Performance
by noonat on Sunday August 27, 2017 @06:23PM
(#15113143)
You're correct. The spec only specifies that "onFulfilled or onRejected must not be called until the execution context stack contains only platform code." This doesn't require that the implementation use the same macro-task scheduling mechanism that setTimeout might use.
> The problem is that Promises have to be resolved in the next turn of the event loop. This is part of the spec.
That statement is false unless I'm missing something major here. Promises aren't resolved in the next turn of the event loop. They should be resolved as part of the microtask queue which can happen at the end of the tick (recursively).
Example (tested on node 8):
Result: The same will happen with async functions: