-
Notifications
You must be signed in to change notification settings - Fork 284
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
event loop tick id #1740
Comments
there is a nodejs/node#25378 seems to be a good candidate for exposing it, if at all. @jasnell |
nodejs/node#22584 could use similar functionality too. |
@ChALkeR can you elaborate on that here? |
Try this: process.currentTickId = (a =>
(b => () => a = a || [b(() => {})])
(process.nextTick = ((b, c) => (...d) => (
c || b(() => a = c = 0, c = 1),
b.apply(process, d)
))(process.nextTick))
)(); |
@ORESoftware , is this issue resolved? any updates? |
inactive, and / or resolved, closing. pls feel free to reopen if required |
On Node.js version 10
Is there a way to access the event loop tick id? The use case is simple: When writing a library you can easily detect whether the user fired a callback synchronously or asynchronously - ultimately the purpose of detecting this is to prevent Zalgo and keep APIs/libraries consistent and performant.
For example, with the async libary, a user can do this:
to my knowledge, the async lib doesn't call process.nextTick on behalf of the user when the user makes this mistake (but the async lib could do that if it wanted to and there was an easily and performant way to check if the user fired the callback in the same tick).
So I am thinking of Node.js API that can allow for detecting the current event loop tick, something like this:
the idea is to prevent someone from calling certain code asynchronously. the only way I know how to do this now is with this hack:
but that's not very performant or convenient. the hack simply relies on the fact that the first process.nextTick call will happen before any other async callbacks get fired.
The text was updated successfully, but these errors were encountered: