From: Jérôme Benoit Date: Mon, 16 Feb 2026 17:58:41 +0000 (+0100) Subject: fix: validate workerNodeKeys on worker ready and remove misleading JSDoc X-Git-Tag: v5.2.0~2 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=456af2f2a433d924b36cf1ed432414cc153a2313;p=poolifier.git fix: validate workerNodeKeys on worker ready and remove misleading JSDoc --- diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index d7de872c2..c85d131d6 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -2005,6 +2005,14 @@ export abstract class AbstractPool< // eslint-disable-next-line @typescript-eslint/restrict-template-expressions throw new Error(`Worker ${workerId?.toString()} failed to initialize`) } + const maxPoolSize = + this.maximumNumberOfWorkers ?? this.minimumNumberOfWorkers + for (const taskFunctionProperties of taskFunctionsProperties ?? []) { + checkValidWorkerNodeKeys( + taskFunctionProperties.workerNodeKeys, + maxPoolSize + ) + } const workerNodeKey = this.getWorkerNodeKeyByWorkerId(workerId) const workerNode = this.workerNodes[workerNodeKey] workerNode.info.ready = ready diff --git a/src/worker/task-functions.ts b/src/worker/task-functions.ts index 8d02f33bc..cce383074 100644 --- a/src/worker/task-functions.ts +++ b/src/worker/task-functions.ts @@ -45,8 +45,6 @@ export interface TaskFunctionObject { * Restricts task execution to specified worker nodes by their indices. * Must contain valid indices within [0, pool max size - 1]. * If undefined, task can execute on any worker node. - * @remarks `null` is not accepted here. Use `null` only via - * {@link TaskFunctionProperties.workerNodeKeys} to clear affinity at runtime. */ workerNodeKeys?: number[] }