From 0dd90fe1089e9852ecea1188dcb8856dbc5de83f Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 1 Sep 2023 12:16:42 +0200 Subject: [PATCH] fix: array out of bound in WRR MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../weighted-round-robin-worker-choice-strategy.ts | 3 +++ 1 file changed, 3 insertions(+) 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 && -- 2.34.1