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: fix refresh did not call active to make the node exit early. #28192

Closed
wants to merge 1 commit into from
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);