From: Jérôme Benoit Date: Thu, 21 Dec 2023 10:57:58 +0000 (+0100) Subject: fix: fix possible null exception at pool destroying X-Git-Tag: v3.1.8~1 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=ad3836edfc48e394c0271633acfa6952ef7be3d6;p=poolifier.git fix: fix possible null exception at pool destroying Signed-off-by: Jérôme Benoit --- diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ba9080d..08678501 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- Fix default worker weight computation. +- Fix possible null exception at pool destroying. + ## [3.1.7] - 2023-12-20 ### Fixed diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index 263d1302..9045b063 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -985,7 +985,7 @@ export abstract class AbstractPool< private async sendKillMessageToWorker (workerNodeKey: number): Promise { await new Promise((resolve, reject) => { if (this.workerNodes?.[workerNodeKey] == null) { - reject(new Error(`Invalid worker node key '${workerNodeKey}'`)) + resolve() return } const killMessageListener = (message: MessageValue): void => { diff --git a/tests/pools/abstract-pool.test.mjs b/tests/pools/abstract-pool.test.mjs index 0ea921f8..78fcd2da 100644 --- a/tests/pools/abstract-pool.test.mjs +++ b/tests/pools/abstract-pool.test.mjs @@ -1666,11 +1666,6 @@ describe('Abstract pool test suite', () => { await expect( pool.sendKillMessageToWorker(workerNodeKey) ).resolves.toBeUndefined() - await expect( - pool.sendKillMessageToWorker(numberOfWorkers) - ).rejects.toStrictEqual( - new Error(`Invalid worker node key '${numberOfWorkers}'`) - ) await pool.destroy() })