Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
timers: don't close interval timers when unrefd
This change fixes a regression introduced by commit
0d05123, which contained a typo that
would cause every unrefd interval to fire only once.

Fixes: nodejs/node-v0.x-archive#8900
Reviewed-By: Timothy J Fontaine <tjfontaine@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
  • Loading branch information
Julien Gilli authored and indutny committed Apr 3, 2015
commit 31d880112f1300fa4631d0b4d45a612a3e7d911c
2 changes: 1 addition & 1 deletion lib/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ const Timeout = function(after) {

function unrefdHandle() {
this.owner._onTimeout();
if (!this.owner.repeat)
if (!this.owner._repeat)
this.owner.close();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will run this._handle.close() which runs uv_close(wrap->handle__, OnClose). Are we sure that the list of timers attached to this TimerWrap instance is empty before this runs?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No list attached here for sure.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great. then LGTM.

}

Expand Down
18 changes: 18 additions & 0 deletions test/parallel/test-timers-unrefd-interval-still-fires.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* This test is a regression test for joyent/node#8900.
*/
var assert = require('assert');

var N = 5;
var nbIntervalFired = 0;
var timer = setInterval(function() {
++nbIntervalFired;
if (nbIntervalFired === N)
clearInterval(timer);
}, 1);

timer.unref();

setTimeout(function onTimeout() {
assert.strictEqual(nbIntervalFired, N);
}, 100);