-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Unreferenced timers run during beforeExit
timeframe
#14171
Comments
Thanks for reporting this issue here! The reproduction code adds a listener on
My understanding is that these two issues can be fixed separately, and that it would help to have two separate issues for them. Am I correct or am I missing something? |
The placement of the assertion is intentional.
Due to some of my digging in nodejs/node#1152 (port of the original unref leak fix) that was suggested to fix nodejs/node#1151 does not actually), we've unearthed several test cases where things go pretty banannas (see: nodejs/node#1191). As mentioned in the cross-posted issue, @bnoordhuis is working on a re-write, because the timers module is pretty incomprehensible. |
The description of this issue mentions that "The gist of the problem is the beforeExit implementation", but the reproduction code doesn't add any listener on the |
I think the situation ended up being that the timer ends up re-running during the |
@Fishrock123 My understanding is that the problem for issue 1) is in the way Node.js uses Issue 2) seems to be related specifically to the fact that there's no mechanism in place to make sure |
@misterdjules the issue is caused by the No What I meant by "beforeExit timeframe" was the application timeframe when |
@brycebaril OK yes, I see what you mean now, and thank you for the clarification. It was introduced by that commit, but specifically by the use of |
@misterdjules great research! Thanks for the gist |
I'm available to guide anyone willing to pick this issue up and submit a PR that fixes it. Ping me on GitHub by mentioning @misterdjules or find me on IRC (jgi in #libuv on Freenode). EDIT: I'm also available by email at jgilli at fastmail dot fm. |
This issue is now tracked by nodejs/node#1264, so closing to avoid confusion. |
Thanks @misterdjules. 👍 |
Cross-posting from nodejs/node#1264
The gist of the problem is the
beforeExit
implementation causes inconsistent and racy situations in timers when the application is closing, a race which can result in an application failing to close and hanging on unreferenced timers. Unreferenced timers will be executed when they shouldn't have been, and will keep the application alive longer as a result.Sample code:
0.12.1:
0.10.38
This impacts 0.11.12 and higher, including 0.12.0 and 0.12.1.
It works as expected in 0.10 (which has no
beforeExit
)The text was updated successfully, but these errors were encountered: