fix: refine possible null exception fix at task response handling
[poolifier.git] / src / pools / selection-strategies / round-robin-worker-choice-strategy.ts
index 19dd3872c116723756fb146a4a57506b10523ab0..7c49cec75689a8ca64aa101b51ec8f86890f1409 100644 (file)
@@ -46,6 +46,7 @@ export class RoundRobinWorkerChoiceStrategy<
     const chosenWorkerNodeKey = this.nextWorkerNodeKey
     this.setPreviousWorkerNodeKey(chosenWorkerNodeKey)
     this.roundRobinNextWorkerNodeKey()
+    this.checkNextWorkerNodeReadiness()
     return chosenWorkerNodeKey
   }
 
@@ -70,12 +71,10 @@ export class RoundRobinWorkerChoiceStrategy<
   }
 
   private roundRobinNextWorkerNodeKey (): number | undefined {
-    do {
-      this.nextWorkerNodeKey =
-        this.nextWorkerNodeKey === this.pool.workerNodes.length - 1
-          ? 0
-          : (this.nextWorkerNodeKey ?? this.previousWorkerNodeKey) + 1
-    } while (!this.isWorkerNodeReady(this.nextWorkerNodeKey))
+    this.nextWorkerNodeKey =
+      this.nextWorkerNodeKey === this.pool.workerNodes.length - 1
+        ? 0
+        : (this.nextWorkerNodeKey ?? this.previousWorkerNodeKey) + 1
     return this.nextWorkerNodeKey
   }
 }