X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fselection-strategies%2Fleast-busy-worker-choice-strategy.ts;h=8db32ac7f1421330e36d9bfb81bddf53392a666c;hb=bcf1c155ec2e2d9208c8f818abd031662bd61d7f;hp=0f2e123979561ce811fc7d81f9334b9d5d837e83;hpb=39618ede0e08d380c1ac82005bcc2ab1f3c227b6;p=poolifier.git diff --git a/src/pools/selection-strategies/least-busy-worker-choice-strategy.ts b/src/pools/selection-strategies/least-busy-worker-choice-strategy.ts index 0f2e1239..8db32ac7 100644 --- a/src/pools/selection-strategies/least-busy-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/least-busy-worker-choice-strategy.ts @@ -1,5 +1,5 @@ -import { DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS } from '../../utils.js' import type { IPool } from '../pool.js' +import { DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS } from '../utils.js' import type { IWorker } from '../worker.js' import { AbstractWorkerChoiceStrategy } from './abstract-worker-choice-strategy.js' import type { @@ -69,6 +69,9 @@ export class LeastBusyWorkerChoiceStrategy< } private leastBusyNextWorkerNodeKey (): number | undefined { + if (this.pool.workerNodes.length === 0) { + return undefined + } return this.pool.workerNodes.reduce( (minWorkerNodeKey, workerNode, workerNodeKey, workerNodes) => { return this.isWorkerNodeReady(workerNodeKey) &&