-
Notifications
You must be signed in to change notification settings - Fork 330
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
add node:timers module #3346
add node:timers module #3346
Conversation
aef241c
to
04fb5ad
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added inline comments.
Would be nice to add test for active
and unenroll
which are added by this PR
23b0804
to
4085a6d
Compare
4085a6d
to
9d22c45
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we consider changing the global functions in node compat mode?
It weird that globalThis.setTimeout !== nodeTimer.setTimeout
and they return a different type. IIUC globalThis.clearTimeour(nodeTimer.setTimeout(...))
will not work.
Edit: found my original comment
9d22c45
to
aa66c19
Compare
No, that would end up being a breaking change. I can foresee possibly adding a separate compat flag to do so but the ship has already sailed... That said, we could probably make it so that |
In node we can do: const timeout = setTimeout(...);
timeout.refresh(); // crashes, timeout is a number We can not do it in worked (both before or after this PR). One thing that we can do in workerd after this PR is:
Meaning
I don't agree here. I consider this a bug fix that we have to do. That is I think I think there is no rush to merge this PR at least before we discuss an agree on what the behavior should be. I think the behavior introduced in this PR can be implemented in unenv for now. In fact edit: And I think we could safely say that it is a bug fix instead of breaking change. Because the only thing this can break is typing, i.e. workerd currently returns a number but users never do any operation on that number. They might only pass that number to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need more discussion before landing this.
@vicb Whether or not changing global setTimeout/setImmediate is not within the scope of this pull-request. We already have most of the node:timers through the polyfill, hence, this pull-request is not changing anything that isn't out there. Since this enables mysql and there are teams/customers waiting for this pull-request to land, I propose postponing the discussion of globals once this PR lands, and proceed with this PR. |
These are different APIs. Workers is Web compatible first and we're not going to change the behavior of
Strong -1 on this. It's not a bug that We would be absolutely no different than Deno with this. In Deno, like the implementation here, has |
@anonrig you said:
What I said is:
So my understanding is that "teams/customers waiting for this pull-request to land" will be satisfied with the unenv update alone, but please correct me if I am wrong. |
@vicb ... I acknowledge that the situation is unfortunate. Node.js should never have implemented this API in a non-web compatible way, but it did. This is not a reason to block and this is blocking progress on other things. I'm going to dismiss your block so this can proceed. |
aa66c19
to
1a1c7e6
Compare
1a1c7e6
to
2bef052
Compare
Nice one. Ship it! |
Once this lands, we can directly connect to mysql using "mysql" npm package from workers.