Closed
Description
- 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.