From dc02fc29818293c82727cb43ad5014e30aa6a64d Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Thu, 20 Jul 2023 00:49:12 +0200 Subject: [PATCH] refactor: add sanity check at getting worker info MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/pools/abstract-pool.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 } /** -- 2.34.1