fix: fix possible null exception at pool destroying
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 21 Dec 2023 10:57:58 +0000 (11:57 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 21 Dec 2023 10:57:58 +0000 (11:57 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
CHANGELOG.md
src/pools/abstract-pool.ts
tests/pools/abstract-pool.test.mjs

index 1ba9080df8759c37f6e4b2b904b0503b3cc601a0..08678501a0274de614089e486545a82bb5373f0e 100644 (file)
@@ -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
index 263d13026f2474c8fb3eb88694beb28c4277605c..9045b063675a7071d77097ae51d3aa4d7bb9cfcb 100644 (file)
@@ -985,7 +985,7 @@ export abstract class AbstractPool<
   private async sendKillMessageToWorker (workerNodeKey: number): Promise<void> {
     await new Promise<void>((resolve, reject) => {
       if (this.workerNodes?.[workerNodeKey] == null) {
-        reject(new Error(`Invalid worker node key '${workerNodeKey}'`))
+        resolve()
         return
       }
       const killMessageListener = (message: MessageValue<Response>): void => {
index 0ea921f88cfcc9cb77fccfa0c0e77334fe776ecd..78fcd2dac9ab3d994d8f0a13b544799a35fb0fcf 100644 (file)
@@ -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()
   })