]> Piment Noir Git Repositories - poolifier.git/commitdiff
fix: validate workerNodeKeys on worker ready and remove misleading JSDoc
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 16 Feb 2026 17:58:41 +0000 (18:58 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 16 Feb 2026 17:58:41 +0000 (18:58 +0100)
src/pools/abstract-pool.ts
src/worker/task-functions.ts

index d7de872c25642d13c686ae7f0909d4d13c094784..c85d131d655f73a8f13f1575c89f446d1cc08717 100644 (file)
@@ -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
index 8d02f33bcffe88a1878bd35c64a572de6175bcf9..cce38307478b1f668e878c197a2bb55dc572ed83 100644 (file)
@@ -45,8 +45,6 @@ export interface TaskFunctionObject<Data = unknown, Response = unknown> {
    * 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[]
 }