fix: fix possible null exception with worker_threads pools
[poolifier.git] / src / pools / cluster / dynamic.ts
index a9ccd6977255bcadc43bee150d8684a3ee3ad75e..99a89966e914507fa6868883a0f67c751c8b29c6 100644 (file)
@@ -1,4 +1,5 @@
 import { type PoolType, PoolTypes } from '../pool'
+import { checkDynamicPoolSize } from '../utils'
 import { type ClusterPoolOptions, FixedClusterPool } from './fixed'
 
 /**
@@ -31,6 +32,7 @@ export class DynamicClusterPool<
     opts: ClusterPoolOptions = {}
   ) {
     super(min, filePath, opts)
+    checkDynamicPoolSize(this.numberOfWorkers, this.max)
   }
 
   /** @inheritDoc */
@@ -38,11 +40,6 @@ export class DynamicClusterPool<
     return PoolTypes.dynamic
   }
 
-  /** @inheritDoc */
-  protected get maxSize (): number {
-    return this.max
-  }
-
   /** @inheritDoc */
   protected get busy (): boolean {
     return this.full && this.internalBusy()