Uh oh!
There was an error while loading. Please reload this page.
Port from joyent/node: timers: fix timeout when added in timer's callback - #2232
Port from joyent/node: timers: fix timeout when added in timer's callback#2232Fishrock123 wants to merge 3 commits into
timers: fix timeout when added in timer's callback#2232Conversation
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#9333Fixes: 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
timers: fix timeout when added in timer's callbackThere was a problem hiding this comment.
This catch block and the function is not finished, I think
There was a problem hiding this comment.
Oops, that was a merge conflict mis-resolve.
whitlockjc
commented
Jul 24, 2015
I wouldn't mind helping port nodejs/node-v0.x-archive#25763 if it's not already been done. |
Fishrock123
commented
Jul 24, 2015
@whitlockjc I'll be yeah, I figured I'd probably let Julien review it over there first. |
Fishrock123
commented
Jul 27, 2015
Updated, PTAL @misterdjules / @bnoordhuis |
There was a problem hiding this comment.
Date.now() here and two lines up?
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
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.
bnoordhuis
commented
Jul 27, 2015
LGTM with suggestions. The 100 ms timeout may end up being flaky on some of the CI machines. |
Fishrock123
commented
Jul 28, 2015
Hmm, getting this with the patch locally: 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 |
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?
jasnell
commented
Aug 23, 2015
@Fishrock123 ... what's the status on this one? |
Fishrock123
commented
Aug 23, 2015
@jasnell was waiting on nodejs/node-v0.x-archive#25763 |
misterdjules
commented
Oct 1, 2015
@Fishrock123 The failure in Since nodejs/node-v0.x-archive#25763 fixes this problem. |
Fishrock123
commented
Jan 11, 2016
closing in favor of #3063 |
whitlockjc
commented
Jul 7, 2016
#3063 has been updated to include this change and the test/parallel/test-timers-blocking-callback.js test per @misterdjules' request. |
We'll probably also want to port nodejs/node-v0.x-archive#25763
cc @misterdjules / @bnoordhuis