Closed
Description
- Version: 7.2.0
- Platform: Ubuntu 16.10 64-bit
When the delay is set to 1
, for about 5% of cases the logged time between executing setTimeout()
and the callback execution is 0
.
// main.js
const timeJustBeforeCallingSetTimeout = Date.now();
setTimeout(() => {
const callbackExecutionTime = Date.now();
console.log(callbackExecutionTime - timeJustBeforeCallingSetTimeout);
}, 1);
# bash script that runs above code 1000 times and counts cases when 0 is logged
rm -f results.txt
for ((n=0; n<1000; n++))
do
node main.js >> results.txt
done
cat results.txt | grep 0 | wc -l
When the delay value is set to 2
, there are no cases where the logged time is less than 2, which is an expected behavior.