Skip to content

use queueMicrotask instead of setTimeout in browsers to avoid browser throttling#1761

Merged
aearly merged 1 commit intocaolan:masterfrom
jensengar:fix-browser-throttling
Aug 5, 2021
Merged

use queueMicrotask instead of setTimeout in browsers to avoid browser throttling#1761
aearly merged 1 commit intocaolan:masterfrom
jensengar:fix-browser-throttling

Conversation

@jensengar
Copy link
Copy Markdown
Contributor

Since setTimeout get throttled by browsers and setImmediate doesn't actually exist in any browsers, we should use queueMicrotask which works very similarly to the intention of setImmediate.

I have an app that uses stanza.io which relies on async's priorityQueue. It was found that priorityQueue is getting throttled because of its use of setTimeout(fn, 0). Most browsers support queueMicrotask, but for those who don't, we will fallback.

@djhouseknecht
Copy link
Copy Markdown

For reference:

@jensengar
Copy link
Copy Markdown
Contributor Author

@sauravazad thanks for the approval. Is there anyone else who needs to approve this? And who has merge/release rights for this?

@aearly
Copy link
Copy Markdown
Collaborator

aearly commented Aug 5, 2021

I'll merge this later today.

@aearly aearly merged commit 89255fe into caolan:master Aug 5, 2021
@aearly
Copy link
Copy Markdown
Collaborator

aearly commented Aug 5, 2021

Published in v3.2.1

@jensengar
Copy link
Copy Markdown
Contributor Author

Thanks!

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

Successfully merging this pull request may close these issues.

4 participants