refactor: refine worker node existence test
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 20 Dec 2023 18:38:36 +0000 (19:38 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 20 Dec 2023 18:38:36 +0000 (19:38 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
src/pools/abstract-pool.ts

index 4bfc3acbc47fb80b001f54f2ab429937fa46e2a9..263d13026f2474c8fb3eb88694beb28c4277605c 100644 (file)
@@ -984,7 +984,7 @@ export abstract class AbstractPool<
 
   private async sendKillMessageToWorker (workerNodeKey: number): Promise<void> {
     await new Promise<void>((resolve, reject) => {
-      if (workerNodeKey < 0 || workerNodeKey >= this.workerNodes.length) {
+      if (this.workerNodes?.[workerNodeKey] == null) {
         reject(new Error(`Invalid worker node key '${workerNodeKey}'`))
         return
       }