Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,9 @@ Timeout.prototype.unref = function() {
}

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

this._handle = handle || new TimerWrap();
this._handle.owner = this;
Expand Down
14 changes: 14 additions & 0 deletions test/parallel/test-timers-unref-reuse-no-exposed-list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need a license block now that #10155 landed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... No? It did not have previous attribution? (It's new?)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, it's been a while I haven't added a file to the repository, and it seems files added in the recent past did not include a license block, so it sounds good to me!


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