- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 33.7k
 
Closed
Labels
blockedPRs that are blocked by other issues or PRs.PRs that are blocked by other issues or PRs.libuvIssues and PRs related to the libuv dependency or the uv binding.Issues and PRs related to the libuv dependency or the uv binding.questionIssues that look for answers.Issues that look for answers.timersIssues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout.Issues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout.
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 -lWhen the delay value is set to 2, there are no cases where the logged time is less than 2, which is an expected behavior.
ikokostya
Metadata
Metadata
Assignees
Labels
blockedPRs that are blocked by other issues or PRs.PRs that are blocked by other issues or PRs.libuvIssues and PRs related to the libuv dependency or the uv binding.Issues and PRs related to the libuv dependency or the uv binding.questionIssues that look for answers.Issues that look for answers.timersIssues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout.Issues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout.