mirror of
https://github.com/nodejs/node.git
synced 2025-04-28 13:40:37 +00:00

When `timers.refresh()` is called inside a callback, the timer would incorrectly end up unrefed and thus not keep the event loop alive. PR-URL: https://github.com/nodejs/node/pull/26721 Fixes: https://github.com/nodejs/node/issues/26642 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Weijia Wang <starkwang@126.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
15 lines
321 B
JavaScript
15 lines
321 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
// This test checks whether a refresh called inside the callback will keep
|
|
// the event loop alive to run the timer again.
|
|
|
|
let didCall = false;
|
|
const timer = setTimeout(common.mustCall(() => {
|
|
if (!didCall) {
|
|
didCall = true;
|
|
timer.refresh();
|
|
}
|
|
}, 2), 1);
|