diff --git a/lib/timers.js b/lib/timers.js index 302a11e18b5624..442789439bc7c2 100644 --- a/lib/timers.js +++ b/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(); } diff --git a/test/parallel/test-timers-unrefd-interval-still-fires.js b/test/parallel/test-timers-unrefd-interval-still-fires.js new file mode 100644 index 00000000000000..3ea94454cfdb49 --- /dev/null +++ b/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);