From d4a65aabb0523bc0f4d87eaefb7db2fd4df1fa53 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Wed, 28 Feb 2024 12:53:11 -0500 Subject: [PATCH] fix: unref timers implicitly scheduled for MAX_TIMEOUT --- lib/runnable.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/runnable.js b/lib/runnable.js index 98327bf5d9..363b67639f 100644 --- a/lib/runnable.js +++ b/lib/runnable.js @@ -234,7 +234,7 @@ Runnable.prototype.clearTimeout = function () { */ Runnable.prototype.resetTimeout = function () { var self = this; - var ms = this.timeout() || MAX_TIMEOUT; + var ms = this.timeout(); this.clearTimeout(); this.timer = setTimeout(function () { @@ -243,7 +243,11 @@ Runnable.prototype.resetTimeout = function () { } self.callback(self._timeoutError(ms)); self.timedOut = true; - }, ms); + }, ms || MAX_TIMEOUT); + + if (!ms) { + this.timer.unref(); + } }; /**