fix: ensure worker choice is retried at least the pool max size
[poolifier.git] / src / pools / cluster / dynamic.ts
index 32aad22a738c8541a4147ebbad7a3048ff51f8af..9f2f0dd95130a37d4bf010b071dbcc30271ab9ac 100644 (file)
@@ -28,12 +28,15 @@ export class DynamicClusterPool<
    */
   public constructor (
     min: number,
-    protected readonly max: number,
+    max: number,
     filePath: string,
     opts: PoolOptions<Worker> = {}
   ) {
-    super(min, filePath, opts)
-    checkDynamicPoolSize(this.numberOfWorkers, this.max)
+    super(min, filePath, opts, max)
+    checkDynamicPoolSize(
+      this.minimumNumberOfWorkers,
+      this.maximumNumberOfWorkers as number
+    )
   }
 
   /** @inheritDoc */