fix: array out of bound in WRR
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Fri, 1 Sep 2023 10:16:42 +0000 (12:16 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Fri, 1 Sep 2023 10:16:42 +0000 (12:16 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts

index c87081a6161c82ab612d5aca2b37a49e6b1089b0..b023bfb0cd258641354c81c465c20fa9a3b0b309 100644 (file)
@@ -81,6 +81,9 @@ export class WeightedRoundRobinWorkerChoiceStrategy<
     }
     if (this.nextWorkerNodeKey === workerNodeKey) {
       this.workerVirtualTaskRunTime = 0
+      if (this.nextWorkerNodeKey > this.pool.workerNodes.length - 1) {
+        this.nextWorkerNodeKey = this.pool.workerNodes.length - 1
+      }
     }
     if (
       this.previousWorkerNodeKey === workerNodeKey &&