| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
When a timer is added in another timer's callback, its underlying timer handle will be started with a timeout that is actually incorrect. The reason is that the value that represents the current time is not updated between the time the original callback is called and the time the added timer is processed by timers.listOnTimeout. That leads the logic in timers.listOnTimeout to do an incorrect computation that makes the added timer fire with a timeout of scheduledTimeout + timeSpentInCallback. This change fixes that and make timers scheduled within other timers' callbacks fire as expected. Fixes: nodejs/node-v0.x-archive#9333 Fixes: nodejs/node-v0.x-archive#15447 PR: nodejs/node-v0.x-archive#17203 PR-URL: nodejs/node-v0.x-archive#17203 Reviewed-By: Fedor Indutny <fedor@indutny.com> Conflicts: lib/timers.js test/common.js
There was a problem hiding this comment.
This catch block and the function is not finished, I think
Sorry, something went wrong.
There was a problem hiding this comment.
Oops, that was a merge conflict mis-resolve.
Sorry, something went wrong.
|
I wouldn't mind helping port nodejs/node-v0.x-archive#25763 if it's not already been done. |
Sorry, something went wrong.
|
@whitlockjc I'll be yeah, I figured I'd probably let Julien review it over there first. |
Sorry, something went wrong.
|
Updated, PTAL @misterdjules / @bnoordhuis |
Sorry, something went wrong.
There was a problem hiding this comment.
Date.now() here and two lines up?
Sorry, something went wrong.
There was a problem hiding this comment.
Hmm, in the new patch joyent/node will be using Timer.now() -- what's the difference between it and Date.now()?
https://github.com/joyent/node/pull/25763/files#diff-8736c5cbff21e1dee18b0c86d3d2689dR226
Sorry, something went wrong.
There was a problem hiding this comment.
Timer.now() has a fighting chance of fitting in an SMI (a tagged integer), the return value of Date.now() is always a heap-allocated double.
Sorry, something went wrong.
|
LGTM with suggestions. The 100 ms timeout may end up being flaky on some of the CI machines. |
Sorry, something went wrong.
|
Hmm, getting this with the patch locally: === release test-timers-unref-call === Path: parallel/test-timers-unref-call Command: out/Release/iojs /Users/Jeremiah/Documents/io.js/test/parallel/test-timers-unref-call.js --- TIMEOUT --- I'm guessing that test exposes something wrong with this patch, since the test is not present in joyent/node. Perhaps the same bug nodejs/node-v0.x-archive#25763 is attempting to rectify? Test origin commit: ebf9f29 |
Sorry, something went wrong.
There was a problem hiding this comment.
const? Also do we really need this? I mean we can directly use Date.now() in the following statement no?
Sorry, something went wrong.
There was a problem hiding this comment.
Ah nice, true.
Sorry, something went wrong.
|
@Fishrock123 ... what's the status on this one? |
Sorry, something went wrong.
|
@jasnell was waiting on nodejs/node-v0.x-archive#25763 |
Sorry, something went wrong.
|
@Fishrock123 The failure in test/parallel/test-timers-unref-call.js is due to a problem with the original change being ported that executes nested timers callbacks in the same tick. Since test/parallel/test-timers-unref-call.js overrides Timer.now to always advance the current time, and because the timer delay is initially 1ms (but really one "tick" or one Timer.now call with this override), the new timers added by setInterval's callback are always ready to fire, and always do indefinitely. nodejs/node-v0.x-archive#25763 fixes this problem. |
Sorry, something went wrong.
|
#3063 has been updated to include this change and the test/parallel/test-timers-blocking-callback.js test per @misterdjules' request. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
We'll probably also want to port nodejs/node-v0.x-archive#25763
cc @misterdjules / @bnoordhuis