-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Repeat unref'd interval persists program until next interval #7327
Comments
The uv loop should have exited after the setTimeout timeout. |
That will be good as this has been bothering me for some time. I am developing a service app, but when signalled to shut down, it sometimes takes up 150s to exit. Using NODE_DEBUG="net timers" exposed an unknown 150s interval that I am guessing is gc() related and which sometimes delays the exit depending on whether the service has been running long enough. Question - is there a way to audit the uv loop to see concisely what is preventing exit at any given moment? |
I think your problem has nothing to do with gc. |
Gc() was just speculation, as the 150s interval is not mine, at least not directly. have you been able to repro? |
yes. I can reproduce it. |
Any conclusions on whether this is a bug or a feature? If a bug, how long might the fix take to arrive is a stable release of Node ? |
Question: what is preventing exit? |
Thanks, I'll enjoy exploring those calls. |
This is not a bug. It's just the action of timer of unref. |
I am surprised given your opening view that 'The uv loop should have exited after the setTimeout timeout' Is there a way to avoid this delayed exit behaviour? |
The callback of setInterval will start next timer for 3000ms in your code, which is not the only item in the uv loop. |
I am unable to make sense of the explanation, The actual behaviour seems to be at odds with the specified behaviour; because following the timeout, only the unref'd interval is outstanding, so should not prevent program exit. Sadly, nobody else seems interested in expressing a view so it appears I shall have to live with it. Thank you for looking into it. |
I cannot get this to reproduce, what's your environment? (platform, arch, version) |
environment: v0.10.26 Windows7 x64 |
0.10.26, 0.11.12 — reproduces on OS X 10.9.1 |
Further investigation using a modified version of the test script (given below) reveals an var unref_interval = 0; setInterval(function() { ++unref_interval; }, 300).unref(); setTimeout(function() {}, +process.argv[2] * 300 + 50); process.on('exit', function() { console.log('intervals: ' + unref_interval); }); Example runs: # node 7327.js 0 intervals: 0 # node 7327.js 1 intervals: 2 # node 7327.js 2 intervals: 2 # node 7327.js 3 intervals: 4 # node 7327.js 4 intervals: 4 # node 7327.js 5 intervals: 6 # node 7327.js 6 intervals: 6 This seems to correlate with the output of So, it seems that an Personally reproduced on: Not sure where this leaves us, but it's distinctly odd. |
Correction from my previous: So, it seems that an |
@mhmeadows63 |
Currently unable to reproduce on osx 10.10.3 with current v0.10 and v0.12 or io.js. Doesn't mean it's resolved yet tho. @joyent/node-coreteam ... thoughts on this one? |
This looks suspiciously like nodejs/node#1231 |
Thanks... I thought I remembered seeing something similar but couldn't recall the specifics. I'll test on windows and ubuntu either later today or monday but I suspect this one has been resolved. |
Closing. Appears to be resolved in io.js. Will pick up the fix or we can backport. |
Bug: Repeat unref'd interval persists program until next interval
After the ref'd timeout fires, the unref'd interval should not persist the program,
... but it does until the next time the unref'd interval fires.
// This is an issue for long unref'd intervals such as for garbage-collection.
The text was updated successfully, but these errors were encountered: