You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
varassert=require("assert")varintervals=0vari=setInterval(function(){intervals++i.unref()eatTime()},10)functioneatTime(){// the goal of this function is to take longer than the intervalvarcount=0while(count++<1e7){Math.random()}}process.on("exit",function(){assert.equal(intervals,1)})
0.12.1:
bryce@x220:/tmp$ node -v
v0.12.1
bryce@x220:/tmp$ node ah14.js
assert.js:86
throw new assert.AssertionError({
^
AssertionError: 3 == 1
at process.<anonymous> (/tmp/ah14.js:17:10)
at process.emit (events.js:107:17)
Cross-posting from nodejs/node#1264
The gist of the problem is the
beforeExitimplementation 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)