fix: ensure worker choice is retried at least the pool max size
[poolifier.git] / src / pools / thread / dynamic.ts
index 6def273e24bcc413a880ad8fa793fad74a9e36d5..b0a22346690bd36c471b6b45c844af8ffae098ea 100644 (file)
@@ -28,12 +28,15 @@ export class DynamicThreadPool<
    */
   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 */