-
Notifications
You must be signed in to change notification settings - Fork 28.3k
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
timers: emit process warning if delay is negative or NaN #46678
base: main
Are you sure you want to change the base?
timers: emit process warning if delay is negative or NaN #46678
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
bf96237
to
0f7f6f1
Compare
0f7f6f1
to
e788632
Compare
I personally would prefer to add |
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.
Hi I think this would require a test too that the warning is emitted as per the conditions
Hi Debadree, I was wondering if we should add a new warning name(s) to address negative number and |
Didn't get you here 😅 new name for the warning? |
Sorry, I was trying to refer to here, when the delay is greater than |
Ah, I think having a name would be a good thing, would follow the pattern and make it easier to test maybe something like |
Sorry, I didn't know that when you request a new review would remove the existing review request 😅 |
81c846e
to
8da4a3b
Compare
I forgot to rebase @debadree25 sorry, would you mind running the workflows again 🙏 |
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.
The code looks good! will wait for a few more reviews!
This comment was marked as off-topic.
This comment was marked as off-topic.
Yup. |
Sorry guys, its been a while. Just wanted to get a bit of directions, are you guys happy with the current state of the code or want me to make more changes (e.g. emit error per process for negative number and NaN) |
I think lets make it once per process and land it! |
Emit process warning when delay is a negative number or not a number, this will keep the consistency of the warning message for `TIMEOUT_MAX` number As the negative number will be set to 1 by default.
593c1aa
to
35f3752
Compare
db30941
to
807b7c3
Compare
There is a bit of inconsistency in NodeJS docs here it says
It didn't say optional, while MDN specifically says Anyway... This PR will emit warning on code like this: setTimeout(() =>{ /* do something */ }) Should we do this to the after === undefined ? 1 : after *= 1; // Coalesce to number or NaN ping @jasnell @debadree25 👀 |
I think we should not emit a warning in the case of |
Agreed @debadree25, patched a fix so it will only emit when the argument is invalid. |
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.
This should follow the usual deprecation cycle – i.e. first a doc-only deprecation should land, then this PR can land as semver-major turning it into a runtime deprecation.
Hi @aduh95 thanks for the feedback! Can I quickly ask about the deprecation part, as I didn't see if there is any deprecation in my PR, just wondering if I am missing out something. |
ping @aduh95 👀 |
Would be great if I can get a bit more direction on this PR. |
Sorry for missing your previous pings! What's being deprecated is passing Before this PR: $ node -e 'setInterval(console.log,-1).close();setInterval(console.log,NaN).close();setTimeout(console.log,-1);setTimeout(console.log,NaN)'
With this PR: $ node -e 'setInterval(console.log,-1).close();setInterval(console.log,NaN).close();setTimeout(console.log,-1);setTimeout(console.log,NaN)'
(node:43520) TimeoutNegativeWarning: -1 is a negative number.
Timeout duration was set to 1.
(Use `node --trace-warnings ...` to show where the warning was created)
(node:43520) TimeoutNaNWarning: NaN is not a number.
Timeout duration was set to 1.
As you can see, code that was working before is now emitting a warning. node/doc/contributing/collaborator-guide.md Lines 356 to 363 in 956521c
node/doc/contributing/collaborator-guide.md Lines 475 to 497 in 956521c
|
Much thanks! Now I understood. |
Partially addressed #46596 to keep the consistency of the warning message for
TIMEOUT_MAX
number as the negative number,NaN
will be set to1
as well.