Browse Source

timers: don't close interval timers when unrefd

This change fixes a regression introduced by commit
0d051238be, which contained a typo that
would cause every unrefd interval to fire only once.

Fixes: https://github.com/joyent/node/issues/8900
Reviewed-By: Timothy J Fontaine <tjfontaine@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
v1.8.0-commit
Julien Gilli 10 years ago
committed by Fedor Indutny
parent
commit
cca5efb086
  1. 2
      lib/timers.js
  2. 18
      test/parallel/test-timers-unrefd-interval-still-fires.js

2
lib/timers.js

@ -304,7 +304,7 @@ const Timeout = function(after) {
function unrefdHandle() {
this.owner._onTimeout();
if (!this.owner.repeat)
if (!this.owner._repeat)
this.owner.close();
}

18
test/parallel/test-timers-unrefd-interval-still-fires.js

@ -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);
Loading…
Cancel
Save