From: Jérôme Benoit Date: Wed, 19 Jul 2023 22:49:12 +0000 (+0200) Subject: refactor: add sanity check at getting worker info X-Git-Tag: v2.6.19~7 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=dc02fc29818293c82727cb43ad5014e30aa6a64d;p=poolifier.git refactor: add sanity check at getting worker info Signed-off-by: Jérôme Benoit --- diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index ddf4cbcc..be1402a7 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -1066,7 +1066,11 @@ export abstract class AbstractPool< * @param worker - The worker. */ protected getWorkerInfoByWorker (worker: Worker): WorkerInfo { - return this.workerNodes[this.getWorkerNodeKey(worker)].info + const workerNodeKey = this.getWorkerNodeKey(worker) + if (workerNodeKey === -1) { + throw new Error('Worker not found') + } + return this.workerNodes[workerNodeKey].info } /**