fix: fix pool starting detection
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 11 Jul 2023 19:58:25 +0000 (21:58 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Tue, 11 Jul 2023 19:58:25 +0000 (21:58 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/pools/abstract-pool.ts

index b43d44a59eea1cb1c7990e660b96cb4cd5483a03..50ce2026d4f2e17f182f773227c2bc51f22de26f 100644 (file)
@@ -84,6 +84,10 @@ export abstract class AbstractPool<
   Response
   >
 
+  /**
+   * Whether the pool is starting.
+   */
+  private readonly starting: boolean
   /**
    * The start timestamp of the pool.
    */
@@ -128,6 +132,7 @@ export abstract class AbstractPool<
 
     this.setupHook()
 
+    this.starting = true
     while (
       this.workerNodes.reduce(
         (accumulator, workerNode) =>
@@ -137,6 +142,7 @@ export abstract class AbstractPool<
     ) {
       this.createAndSetupWorker()
     }
+    this.starting = false
 
     this.startTimestamp = performance.now()
   }
@@ -416,16 +422,6 @@ export abstract class AbstractPool<
     }
   }
 
-  private get starting (): boolean {
-    return (
-      this.workerNodes.reduce(
-        (accumulator, workerNode) =>
-          !workerNode.info.dynamic ? accumulator + 1 : accumulator,
-        0
-      ) < this.minSize
-    )
-  }
-
   private get ready (): boolean {
     return (
       this.workerNodes.reduce(