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

setTimeout is not working properly with non-integer in Node 11 #24203

Closed
suguru03 opened this issue Nov 6, 2018 · 8 comments
Closed

setTimeout is not working properly with non-integer in Node 11 #24203

suguru03 opened this issue Nov 6, 2018 · 8 comments
Labels
confirmed-bug Issues with confirmed bugs. timers Issues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout.

Comments

@suguru03
Copy link
Contributor

suguru03 commented Nov 6, 2018

  • Version: v11.1.0
  • Platform:Darwin suguru 17.7.0 Darwin Kernel Version 17.7.0: Fri Jul 6 19:54:51 PDT 2018; root:xnu-4570.71.3~2/RELEASE_X86_64 x86_64
  • Subsystem: timers

I have tested setTimeout and realized the function seems to have an issue when it is called with non-integer, such as 1.1 * 100 (110.00000000000001).
The function will stop calling a callback function randomly and eat up high CPU usage.
The code is as below,

const time = 1.1 * 100;
console.log(`time: ${time}`);

function exec(i) {
  console.log(i);
  setTimeout(exec, time, ++i);
}
exec(0);
// output
time: 110.00000000000001
0
1
2
3 // process hangs and eats up all CPU

I also tested it in Node v10, but it seems fine.

@addaleax addaleax added the timers Issues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout. label Nov 6, 2018
@addaleax
Copy link
Member

addaleax commented Nov 6, 2018

/cc @apapirovski

@targos
Copy link
Member

targos commented Nov 6, 2018

@nodejs/timers

suguru03 added a commit to suguru03/node that referenced this issue Nov 16, 2018
Fix the timer logic to be the same as v10.30.0.

Fixes: nodejs#24203
@Trott
Copy link
Member

Trott commented Nov 21, 2018

Confirmed to still be a bug in Node.js 11.2.0.

@Fishrock123
Copy link
Contributor

This should be fixed on master.

@Fishrock123 Fishrock123 added the confirmed-bug Issues with confirmed bugs. label Nov 21, 2018
@suguru03
Copy link
Contributor Author

@Trott @Fishrock123 Thanks for the confirmation! 😄
I hope it is fixed soon.

@Trott
Copy link
Member

Trott commented Nov 23, 2018

This should be fixed on master.

@Fishrock123 Sorry to say that this is not fixed on master. The code to replicate above still hangs with an executable compiled from current master.

@Fishrock123
Copy link
Contributor

Oh whoops this wasn't the issue I thought it was...

Trott pushed a commit to Trott/io.js that referenced this issue Dec 1, 2018
Fix the timer logic to be the same as v10.30.0.

Fixes: nodejs#24203

PR-URL: nodejs#24214
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
@Trott
Copy link
Member

Trott commented Dec 1, 2018

Fixed in e9de435

@Trott Trott closed this as completed Dec 1, 2018
BridgeAR pushed a commit that referenced this issue Dec 5, 2018
Fix the timer logic to be the same as v10.30.0.

Fixes: #24203

PR-URL: #24214
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
refack pushed a commit to refack/node that referenced this issue Jan 14, 2019
Fix the timer logic to be the same as v10.30.0.

Fixes: nodejs#24203

PR-URL: nodejs#24214
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug Issues with confirmed bugs. timers Issues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants