Skip to content
Merged
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
5 changes: 4 additions & 1 deletion packages/core/src/autoscaling/autoscaled_pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,11 @@ export class AutoscaledPool {
this.isStopped = true;
await new Promise<void>((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.`,
Expand All @@ -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);
Expand Down
Loading