-
Notifications
You must be signed in to change notification settings - Fork 29.1k
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
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 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. |
8826103
to
e7e7f49
Compare
Emit process warning once per process when delay is a negative number or not a number, this will prevent unexpected behaviour caused by invalid `delay` also keep the consistency of the behaviour and warning message for `TIMEOUT_MAX` number As the negative number is invalid delay will be set to 1.
e7e7f49
to
7c97dbf
Compare
The policy have changes, runtime warnings are now allowed on non-deprecated APIs
Commit Queue failed- Loading data for nodejs/node/pull/46678 ✔ Done loading data for nodejs/node/pull/46678 ----------------------------------- PR info ------------------------------------ Title timers: emit process warning if delay is negative or NaN (#46678) ⚠ Could not retrieve the email or name of the PR author's from user's GitHub profile! Branch jakecastelli:improve-timer-warning-message -> nodejs:main Labels timers, semver-major, author ready, needs-ci, review wanted Commits 3 - timers: emit warning if delay is negative or NaN - fixup! - fixup! lint Committers 1 - jakecastelli <959672929@qq.com> PR-URL: https://github.com/nodejs/node/pull/46678 Reviewed-By: Debadree Chatterjee Reviewed-By: Ulises Gascón Reviewed-By: Benjamin Gruenbaum Reviewed-By: Chengzhong Wu ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/46678 Reviewed-By: Debadree Chatterjee Reviewed-By: Ulises Gascón Reviewed-By: Benjamin Gruenbaum Reviewed-By: Chengzhong Wu -------------------------------------------------------------------------------- ℹ This PR was created on Thu, 16 Feb 2023 01:34:23 GMT ✔ Approvals: 4 ✔ - Debadree Chatterjee (@debadree25): https://github.com/nodejs/node/pull/46678#pullrequestreview-1304735554 ✔ - Ulises Gascón (@UlisesGascon): https://github.com/nodejs/node/pull/46678#pullrequestreview-1314970311 ✔ - Benjamin Gruenbaum (@benjamingr) (TSC): https://github.com/nodejs/node/pull/46678#pullrequestreview-2145179529 ✔ - Chengzhong Wu (@legendecas) (TSC): https://github.com/nodejs/node/pull/46678#pullrequestreview-2145602094 ✔ Last GitHub CI successful ℹ Last Full PR CI on 2024-06-27T16:48:46Z: https://ci.nodejs.org/job/node-test-pull-request/59989/ - Querying data for job/node-test-pull-request/59989/ ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ No git cherry-pick in progress ✔ No git am in progress ✔ No git rebase in progress -------------------------------------------------------------------------------- - Bringing origin/main up to date... From https://github.com/nodejs/node * branch main -> FETCH_HEAD ✔ origin/main is now up-to-date - Downloading patch for 46678 From https://github.com/nodejs/node * branch refs/pull/46678/merge -> FETCH_HEAD ✔ Fetched commits as 764b13d75c0a..970b44b07bef -------------------------------------------------------------------------------- [main 82ecda2b49] timers: emit warning if delay is negative or NaN Author: jakecastelli <959672929@qq.com> Date: Thu Feb 16 11:59:33 2023 +1030 9 files changed, 272 insertions(+), 5 deletions(-) create mode 100644 test/parallel/test-timers-nan-duration-emit-once-per-process.js create mode 100644 test/parallel/test-timers-nan-duration-warning.js create mode 100644 test/parallel/test-timers-negative-duration-warning-emit-once-per-process.js create mode 100644 test/parallel/test-timers-negative-duration-warning.js create mode 100644 test/parallel/test-timers-not-emit-duration-zero.js [main 99160b3ff3] fixup! Author: jakecastelli <959672929@qq.com> Date: Wed Jun 26 11:52:18 2024 +0930 1 file changed, 1 insertion(+), 1 deletion(-) [main e3f8f61393] fixup! lint Author: jakecastelli <959672929@qq.com> Date: Wed Jun 26 14:58:22 2024 +0930 1 file changed, 1 insertion(+), 1 deletion(-) ✔ Patches applied There are 3 commits in the PR. Attempting autorebase. Rebasing (2/6)https://github.com/nodejs/node/actions/runs/9712029958 |
Landed in f5ed338 |
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.