Skip to content

Commit

Permalink
timers: don't close interval timers when unrefd
Browse files Browse the repository at this point in the history
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
1 parent 0e06197 commit cca5efb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
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();
}

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);

0 comments on commit cca5efb

Please sign in to comment.