Skip to content

Commit d249fc2

Browse files
committed
fixup: ref/unref should still work when destroyed
1 parent 33b3eb4 commit d249fc2

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/internal/timers.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,23 +207,25 @@ Timeout.prototype.refresh = function() {
207207
};
208208

209209
Timeout.prototype.unref = function() {
210-
if (this[kRefed] && !this._destroyed) {
210+
if (this[kRefed]) {
211211
this[kRefed] = false;
212-
decRefCount();
212+
if (!this._destroyed)
213+
decRefCount();
213214
}
214215
return this;
215216
};
216217

217218
Timeout.prototype.ref = function() {
218-
if (!this[kRefed] && !this._destroyed) {
219+
if (!this[kRefed]) {
219220
this[kRefed] = true;
220-
incRefCount();
221+
if (!this._destroyed)
222+
incRefCount();
221223
}
222224
return this;
223225
};
224226

225227
Timeout.prototype.hasRef = function() {
226-
return !!(this[kRefed] && !this._destroyed);
228+
return this[kRefed];
227229
};
228230

229231
function TimersList(expiry, msecs) {

0 commit comments

Comments
 (0)