fix: ensure the number of worker choice retries is enough for WRR
[poolifier.git] / src / pools / selection-strategies / abstract-worker-choice-strategy.ts
index 34473ab4e2a3849bc96c6ac02bbe39bbbce3a47a..7324c511cca18f76b89c254f1deb777ae06c2dbe 100644 (file)
@@ -113,7 +113,10 @@ export abstract class AbstractWorkerChoiceStrategy<
   /** @inheritDoc */
   public setOptions (opts: InternalWorkerChoiceStrategyOptions): void {
     this.opts = {
-      ...getDefaultInternalWorkerChoiceStrategyOptions(this.pool.info.maxSize),
+      ...getDefaultInternalWorkerChoiceStrategyOptions(
+        this.pool.info.maxSize +
+          Object.keys((opts?.weights as Record<number, number>) ?? {}).length
+      ),
       ...opts
     }
     this.setTaskStatisticsRequirements(this.opts)