From: Jérôme Benoit Date: Wed, 20 Dec 2023 18:38:36 +0000 (+0100) Subject: refactor: refine worker node existence test X-Git-Tag: v3.1.8~5 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=49beedcb4bf7f6e2885b74f93878e5843d40f282;p=poolifier.git refactor: refine worker node existence test Signed-off-by: Jérôme Benoit --- diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index 4bfc3acb..263d1302 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -984,7 +984,7 @@ export abstract class AbstractPool< private async sendKillMessageToWorker (workerNodeKey: number): Promise { await new Promise((resolve, reject) => { - if (workerNodeKey < 0 || workerNodeKey >= this.workerNodes.length) { + if (this.workerNodes?.[workerNodeKey] == null) { reject(new Error(`Invalid worker node key '${workerNodeKey}'`)) return }