Skip to content
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: 2 additions & 1 deletion lib/internal/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ Timeout.prototype[inspect.custom] = function(_, options) {
};

Timeout.prototype.refresh = function() {
if (this[kRefed])
// Timers that are active or have been invoked.
if (this[kRefed] || this[kRefed] === null)
active(this);
else
unrefActive(this);
Expand Down
12 changes: 12 additions & 0 deletions test/parallel/test-timers-refresh-called.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict';

const common = require('../common');

// Check only timer reactivated by `.refresh()` is in loop,
// only the timer is still active.

const timer = setTimeout(common.mustCall(() => {}, 2), 1);

setTimeout(() => {
timer.refresh();
}, 1);