-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v11.11.0 timeout.refresh()
does not seem to prevent event loop from exiting
#26642
Comments
My guess about possible buggy line was wrong. I changed it but it did not help. Sorry. But that line is part of the problem. When commented out, Lines 345 to 346 in 32853c0
Shouldn't call to
|
Reproduced in 11.11.0 and the master. |
cc @nodejs/timers |
If a timer is refreshed in its callback, we should not decrease `refCount` to prevent exiting event loop ahead of time. Fixes: nodejs#26642
When `timers.refresh()` is called inside a callback, the timer would incorrectly end up unrefed and thus not keep the event loop alive. PR-URL: #26721 Fixes: #26642 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Weijia Wang <starkwang@126.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
v11.11.0
Alpine Linux v3.9
run inside Docker onLinux 03891e4323dc 5.0.0-arch1-1-ARCH #1 SMP PREEMPT Mon Mar 4 14:11:43 UTC 2019 x86_64 Linux
Timers
When using
timeout.refresh
to keep re-running some code, Node.js v11.x exits process, even though timeout is supposed to be "ref'ed" by default (and it is:timeout.hasRef()
returnstrue
every time).I am not 100% sure, but i think it might be caused by this line:
node/lib/timers.js
Line 232 in 32853c0
Shouldn't it look like this instead?
Problem is 100% reproducible with following example (save it to file and run, e.g.,
node test-timer.js
orDEBUG=1 node test-timer.js
):When run on v11.11.0, actual output is incorrect:
When run on v10.15.3, actual output is correct:
Changing amount of time, e.g., from 0 to 1000, does not change the output.
Number assigned to
countdown
does not matter either, as long as it's greater than 1 ;).The text was updated successfully, but these errors were encountered: