From: Jérôme Benoit Date: Fri, 7 Apr 2023 18:00:27 +0000 (+0200) Subject: fix: destroy worker only on check alive checks X-Git-Tag: v2.4.4~5 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=d2097c13847f906e289a80638248343948b7f18a;p=poolifier.git fix: destroy worker only on check alive checks Signed-off-by: Jérôme Benoit --- diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index 2e033fc1..0d583217 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -302,7 +302,8 @@ export abstract class AbstractPool< this.registerWorkerMessageListener(createdWorker, message => { if ( isKillBehavior(KillBehaviors.HARD, message.kill) || - this.getWorkerTasksUsage(createdWorker)?.running === 0 + (message.kill != null && + this.getWorkerTasksUsage(createdWorker)?.running === 0) ) { // Kill received from the worker, means that no new tasks are submitted to that worker for a while ( > maxInactiveTime) void this.destroyWorker(createdWorker) diff --git a/src/pools/cluster/dynamic.ts b/src/pools/cluster/dynamic.ts index 6171ce4e..b84a80ce 100644 --- a/src/pools/cluster/dynamic.ts +++ b/src/pools/cluster/dynamic.ts @@ -27,7 +27,7 @@ export class DynamicClusterPool< */ public constructor ( min: number, - private readonly max: number, + public readonly max: number, filePath: string, opts: ClusterPoolOptions = {} ) { diff --git a/src/pools/thread/dynamic.ts b/src/pools/thread/dynamic.ts index 62ddba9f..d8cc3a74 100644 --- a/src/pools/thread/dynamic.ts +++ b/src/pools/thread/dynamic.ts @@ -28,7 +28,7 @@ export class DynamicThreadPool< */ public constructor ( min: number, - private readonly max: number, + public readonly max: number, filePath: string, opts: PoolOptions = {} ) {