Skip to content

Commit

Permalink
[Squash] set _list to undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
Fishrock123 committed Apr 10, 2017
1 parent 29bd0ce commit 33b213c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 3 additions & 1 deletion lib/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,9 @@ Timeout.prototype.unref = function() {
}

var handle = reuse(this);
if (handle) handle._list = null;
if (handle) {
handle._list = undefined;
}

this._handle = handle || new TimerWrap();
this._handle.owner = this;
Expand Down
7 changes: 3 additions & 4 deletions test/parallel/test-timers-unref-reuse-no-exposed-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
require('../common');
const assert = require('assert');

// In a case of handle re-use, _list should be null rather than undefined.
const timer1 = setTimeout(() => {}, 1).unref();
assert.strictEqual(timer1._handle._list, null,
'timer1._handle._list should be nulled.');
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();
// Note: It is unlikely that this assertion will be hit in a failure.
// Instead, timers.js will likely throw a TypeError internally.
assert.strictEqual(timer2._handle._list, undefined,
'timer2._handle._list should not exist');
'timer2._handle._list should be undefined');

0 comments on commit 33b213c

Please sign in to comment.