Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

process.nextTick is slow #86

Open
jimmywarting opened this issue Jan 11, 2019 · 6 comments
Open

process.nextTick is slow #86

jimmywarting opened this issue Jan 11, 2019 · 6 comments

Comments

@jimmywarting
Copy link

jimmywarting commented Jan 11, 2019

setTimeout is clamped down to 4ms and even more when tab is hidden.
I saw some old PR attempt at using Observer PostMessage immidate and other but you still use setTimeout and that came back and bite us when transferring data webtorrent/webtorrent#1568

Could you look into using something faster then setTimeout?

@calvinmetcalf
Copy link
Collaborator

hey so I replied in the other issue but the gist is that there are some reasons for not putting that fancy fast things in this default library but i have a different library that it might make sense to use.

@tinchoz49
Copy link

What about try to use queueMicrotask and use the old one behavior as a fallback?

@tinchoz49
Copy link

Or if we use https://github.com/calvinmetcalf/immediate we can add support for window.queueMicrotask there :)

@calvinmetcalf
Copy link
Collaborator

the latter is probably a better option, this library get's included in a lot of bundles so the aim is to keep is small

@tinchoz49
Copy link

It's true is everywhere 😄 and I understand your point but if you don't mind I'm going to do a PR with the changes that I was thinking and you can tell me if it's too much.

@alecgibson
Copy link

We've just run into this. It's particularly bad if your test suite relies on nextTick() a lot in a browser environment.

I've tried monkey-patching with the proposed MessageChannel fix I've seen about, and it seems to work well with good compatibility (even back to IE10!). Is there any appetite to move in that direction? I'm happy to put together a pull request, if so?

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

No branches or pull requests

4 participants