From 42b89146a372b639eaaf50fbda9ff16b026b3344 Mon Sep 17 00:00:00 2001 From: Anas Khan Date: Tue, 14 Jul 2026 16:53:09 +0530 Subject: [PATCH] fix(core): clear `AutoscaledPool.pause()` polling interval on timeout (#3847) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Clears a pending `setInterval` on a function call timeout. --------- Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com> Co-authored-by: Jindřich Bär --- packages/core/src/autoscaling/autoscaled_pool.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/core/src/autoscaling/autoscaled_pool.ts b/packages/core/src/autoscaling/autoscaled_pool.ts index 42f7e42e2e35..45e328a8e162 100644 --- a/packages/core/src/autoscaling/autoscaled_pool.ts +++ b/packages/core/src/autoscaling/autoscaled_pool.ts @@ -430,8 +430,11 @@ export class AutoscaledPool { this.isStopped = true; await new Promise((resolve, reject) => { let timeout: NodeJS.Timeout; + let interval: NodeJS.Timeout; if (timeoutSecs) { timeout = setTimeout(() => { + // Clean up the polling interval to prevent it from leaking on timeout. + clearInterval(interval); const err = new Error( "The pool's running tasks did not finish" + `in ${timeoutSecs} secs after pool.pause() invocation.`, @@ -440,7 +443,7 @@ export class AutoscaledPool { }, timeoutSecs); } - const interval = setInterval(() => { + interval = setInterval(() => { if (this._currentConcurrency <= 0) { // Clean up timeout and interval to prevent process hanging. if (timeout) clearTimeout(timeout);