chore: v2.6.11
[poolifier.git] / src / pools / abstract-pool.ts
index 687ae25f7f43154b484fafc27bb27ea7102b3961..c699b5282a7c0b862a4cc16b63ee5dd34637a643 100644 (file)
@@ -158,18 +158,20 @@ export abstract class AbstractPool<
   }
 
   protected checkDynamicPoolSize (min: number, max: number): void {
-    if (this.type === PoolTypes.dynamic && min > max) {
-      throw new RangeError(
-        'Cannot instantiate a dynamic pool with a maximum pool size inferior to the minimum pool size'
-      )
-    } else if (this.type === PoolTypes.dynamic && min === 0 && max === 0) {
-      throw new RangeError(
-        'Cannot instantiate a dynamic pool with a minimum pool size and a maximum pool size equal to zero'
-      )
-    } else if (this.type === PoolTypes.dynamic && min === max) {
-      throw new RangeError(
-        'Cannot instantiate a dynamic pool with a minimum pool size equal to the maximum pool size. Use a fixed pool instead'
-      )
+    if (this.type === PoolTypes.dynamic) {
+      if (min > max) {
+        throw new RangeError(
+          'Cannot instantiate a dynamic pool with a maximum pool size inferior to the minimum pool size'
+        )
+      } else if (min === 0 && max === 0) {
+        throw new RangeError(
+          'Cannot instantiate a dynamic pool with a minimum pool size and a maximum pool size equal to zero'
+        )
+      } else if (min === max) {
+        throw new RangeError(
+          'Cannot instantiate a dynamic pool with a minimum pool size equal to the maximum pool size. Use a fixed pool instead'
+        )
+      }
     }
   }
 
@@ -401,14 +403,16 @@ export abstract class AbstractPool<
 
   private get starting (): boolean {
     return (
-      !this.full ||
-      (this.full && this.workerNodes.some(workerNode => !workerNode.info.ready))
+      this.workerNodes.length < this.minSize ||
+      (this.workerNodes.length >= this.minSize &&
+        this.workerNodes.some(workerNode => !workerNode.info.ready))
     )
   }
 
   private get ready (): boolean {
     return (
-      this.full && this.workerNodes.every(workerNode => workerNode.info.ready)
+      this.workerNodes.length >= this.minSize &&
+      this.workerNodes.every(workerNode => workerNode.info.ready)
     )
   }