Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
fixup: ref/unref should still work when destroyed
  • Loading branch information
apapirovski committed Dec 13, 2019
commit d249fc238be34d039863d479cc7bf80269c7fc03
12 changes: 7 additions & 5 deletions lib/internal/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,23 +207,25 @@ Timeout.prototype.refresh = function() {
};

Timeout.prototype.unref = function() {
if (this[kRefed] && !this._destroyed) {
if (this[kRefed]) {
this[kRefed] = false;
decRefCount();
if (!this._destroyed)
decRefCount();
}
return this;
};

Timeout.prototype.ref = function() {
if (!this[kRefed] && !this._destroyed) {
if (!this[kRefed]) {
this[kRefed] = true;
incRefCount();
if (!this._destroyed)
incRefCount();
}
return this;
};

Timeout.prototype.hasRef = function() {
return !!(this[kRefed] && !this._destroyed);
return this[kRefed];
};

function TimersList(expiry, msecs) {
Expand Down