Browse Source

timers: do not expose .unref()._handle._list

The list is defunct at this point.
I believe this to be in effect a minor defect from
3eecdf9f14

PR-URL: https://github.com/nodejs/node/pull/8422
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Julien Gilli <jgilli@nodejs.org>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
canary-base
Jeremiah Senkpiel 8 years ago
committed by Ruben Bridgewater
parent
commit
11f7dcf91e
No known key found for this signature in database GPG Key ID: F07496B3EB3C1762
  1. 3
      lib/timers.js
  2. 14
      test/parallel/test-timers-unref-reuse-no-exposed-list.js

3
lib/timers.js

@ -598,6 +598,9 @@ Timeout.prototype.unref = function() {
}
var handle = reuse(this);
if (handle) {
handle._list = undefined;
}
this._handle = handle || new TimerWrap();
this._handle.owner = this;

14
test/parallel/test-timers-unref-reuse-no-exposed-list.js

@ -0,0 +1,14 @@
'use strict';
require('../common');
const assert = require('assert');
const timer1 = setTimeout(() => {}, 1).unref();
assert.strictEqual(timer1._handle._list, undefined,
'timer1._handle._list should be undefined');
// Check that everything works even if the handle was not re-used.
setTimeout(() => {}, 1);
const timer2 = setTimeout(() => {}, 1).unref();
assert.strictEqual(timer2._handle._list, undefined,
'timer2._handle._list should be undefined');
Loading…
Cancel
Save