Re:Async Iterators: These Promises Are Killing My Performance
by Arnavion on Monday August 28, 2017 @01:52PM
(#15118620)
You're using poor polyfills if they use setTimeout. Good polyfills [1] use MutationObserver which uses the (a?) microtask queue.
Invoking a Promise's then() callback synchronously is a violation of the spec. IIRC there are some tests to prevent that in the test suite.
[1]: https://github.com/petkaantonov/bluebird/blob/2c9f7a44/src/s...
This is fine, unless you're:
1. Modifying the DOM and hoping to avoid jankiness 2. Trying to work with popup windows, in a browser which deprioritizes setTimeout in all but the focused window.
I ended up implementing https://github.com/krakenjs/zalgo-promise to get around this. It intentionally "releases Zalgo" by allowing promises to be resolved/then'd synchronously, but my belief is this doesn't have to cause bugs if it's used consistently.