fix: fix possible null exception at task finishing
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 15 Jan 2024 20:23:20 +0000 (21:23 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 15 Jan 2024 20:23:20 +0000 (21:23 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
CHANGELOG.md
src/pools/abstract-pool.ts

index bd45199714fc4ae9c100fb05850daedbc653fa0a..936e24085c81eb94df353681e434a7e8e0ca159a 100644 (file)
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ## [Unreleased]
 
+### Fixed
+
+- Fix possible null exception at task finishing handling.
+
 ## [3.1.18] - 2024-01-06
 
 ### Fixed
index 9cc0b3388e998583aa6db98048d5f3e90b9235f4..bc77874ff423bb3ee112f6150db81962ae5d6e69 100644 (file)
@@ -1768,7 +1768,12 @@ export abstract class AbstractPool<
       this.promiseResponseMap.delete(taskId!)
       // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
       workerNode?.emit('taskFinished', taskId)
-      if (this.opts.enableTasksQueue === true && !this.destroying) {
+      if (
+        this.opts.enableTasksQueue === true &&
+        !this.destroying &&
+        // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
+        workerNode != null
+      ) {
         const workerNodeTasksUsage = workerNode.usage.tasks
         if (
           this.tasksQueueSize(workerNodeKey) > 0 &&