From 456af2f2a433d924b36cf1ed432414cc153a2313 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 16 Feb 2026 18:58:41 +0100 Subject: [PATCH] fix: validate workerNodeKeys on worker ready and remove misleading JSDoc --- src/pools/abstract-pool.ts | 8 ++++++++ src/worker/task-functions.ts | 2 -- 2 files changed, 8 insertions(+), 2 deletions(-) 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[] } -- 2.53.0