Re:Async Iterators: These Promises Are Killing My Performance
by jkrems on Sunday August 27, 2017 @05:59PM
(#15113050)
> The fact that promises must be resolved in the next tick is baked into the spec
From all I know, that statement is false. Promises aren't resolved in the next tick. They should be resolved as part of the microtask queue which can happen at the end of the tick (recursively).
Promise.resolve()
.then(() => console.log('1'))
.then(() => console.log('2'))
.then(() => console.log('still the same tick!'));
setTimeout(() => console.log('timeout happening in the next tick'), 0);
Result:
1
2
still the same tick!
timeout happening in the next tick
From all I know, that statement is false. Promises aren't resolved in the next tick. They should be resolved as part of the microtask queue which can happen at the end of the tick (recursively).
Result: