From: Jérôme Benoit Date: Fri, 1 Sep 2023 10:16:42 +0000 (+0200) Subject: fix: array out of bound in WRR X-Git-Tag: v2.6.40~6 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=0dd90fe1089e9852ecea1188dcb8856dbc5de83f;p=poolifier.git fix: array out of bound in WRR Signed-off-by: Jérôme Benoit --- diff --git a/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts b/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts index c87081a6..b023bfb0 100644 --- a/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts @@ -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 &&