{"action":"created","issue":{"url":"https://api.github.com/repos/nodejs/node/issues/10154","repository_url":"https://api.github.com/repos/nodejs/node","labels_url":"https://api.github.com/repos/nodejs/node/issues/10154/labels{/name}","comments_url":"https://api.github.com/repos/nodejs/node/issues/10154/comments","events_url":"https://api.github.com/repos/nodejs/node/issues/10154/events","html_url":"https://github.com/nodejs/node/issues/10154","id":193860596,"number":10154,"title":"setTimeout callback executed before delay elapses","user":{"login":"marzelin","id":13483453,"avatar_url":"https://avatars.githubusercontent.com/u/13483453?v=3","gravatar_id":"","url":"https://api.github.com/users/marzelin","html_url":"https://github.com/marzelin","followers_url":"https://api.github.com/users/marzelin/followers","following_url":"https://api.github.com/users/marzelin/following{/other_user}","gists_url":"https://api.github.com/users/marzelin/gists{/gist_id}","starred_url":"https://api.github.com/users/marzelin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marzelin/subscriptions","organizations_url":"https://api.github.com/users/marzelin/orgs","repos_url":"https://api.github.com/users/marzelin/repos","events_url":"https://api.github.com/users/marzelin/events{/privacy}","received_events_url":"https://api.github.com/users/marzelin/received_events","type":"User","site_admin":false},"labels":[{"id":214431115,"url":"https://api.github.com/repos/nodejs/node/labels/libuv","name":"libuv","color":"bfd4f2","default":false},{"id":151728679,"url":"https://api.github.com/repos/nodejs/node/labels/question","name":"question","color":"cc317c","default":true},{"id":155435976,"url":"https://api.github.com/repos/nodejs/node/labels/timers","name":"timers","color":"f7c6c7","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-12-06T19:21:02Z","updated_at":"2016-12-08T15:14:24Z","closed_at":null,"body":"<!--\r\nThank you for reporting an issue.\r\n\r\nThis issue tracker is for bugs and issues found within Node.js core.\r\nIf you require more general support please file an issue on our help\r\nrepo. https://github.com/nodejs/help\r\n\r\n\r\nPlease fill in as much of the template below as you're able.\r\n\r\nVersion: output of `node -v`\r\nPlatform: output of `uname -a` (UNIX), or version and 32 or 64-bit (Windows)\r\nSubsystem: if known, please specify affected core module name\r\n\r\nIf possible, please provide code that demonstrates the problem, keeping it as\r\nsimple and free of external dependencies as you are able.\r\n-->\r\n\r\n* **Version**: 7.2.0\r\n* **Platform**: Ubuntu 16.10 64-bit\r\n\r\n<!-- Enter your issue details below this comment. -->\r\n\r\nWhen the delay is set to `1`, for about 5% of cases the logged time between executing `setTimeout()` and the callback execution is `0`.\r\n\r\n```js\r\n// main.js\r\nconst timeJustBeforeCallingSetTimeout = Date.now();\r\nsetTimeout(() => {\r\n  const callbackExecutionTime = Date.now();\r\n  console.log(callbackExecutionTime - timeJustBeforeCallingSetTimeout);\r\n}, 1);\r\n```\r\n\r\n```bash\r\n# bash script that runs above code 1000 times and counts cases when 0 is logged\r\nrm -f results.txt\r\nfor ((n=0; n<1000; n++))\r\ndo\r\n  node main.js >> results.txt\r\ndone\r\ncat results.txt | grep 0 | wc -l\r\n```\r\n\r\nWhen the delay value is set to `2`, there are no cases where the logged time is less than 2, which is an expected behavior."},"comment":{"url":"https://api.github.com/repos/nodejs/node/issues/comments/265764271","html_url":"https://github.com/nodejs/node/issues/10154#issuecomment-265764271","issue_url":"https://api.github.com/repos/nodejs/node/issues/10154","id":265764271,"user":{"login":"Fishrock123","id":1093990,"avatar_url":"https://avatars.githubusercontent.com/u/1093990?v=3","gravatar_id":"","url":"https://api.github.com/users/Fishrock123","html_url":"https://github.com/Fishrock123","followers_url":"https://api.github.com/users/Fishrock123/followers","following_url":"https://api.github.com/users/Fishrock123/following{/other_user}","gists_url":"https://api.github.com/users/Fishrock123/gists{/gist_id}","starred_url":"https://api.github.com/users/Fishrock123/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Fishrock123/subscriptions","organizations_url":"https://api.github.com/users/Fishrock123/orgs","repos_url":"https://api.github.com/users/Fishrock123/repos","events_url":"https://api.github.com/users/Fishrock123/events{/privacy}","received_events_url":"https://api.github.com/users/Fishrock123/received_events","type":"User","site_admin":false},"created_at":"2016-12-08T15:14:24Z","updated_at":"2016-12-08T15:14:24Z","body":"@bnoordhuis any idea?"}}
{"actor":{"display_login":"Fishrock123"}}