fix: refine pool statuses handling
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Sun, 24 Dec 2023 19:21:36 +0000 (20:21 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Sun, 24 Dec 2023 19:21:36 +0000 (20:21 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
src/pools/abstract-pool.ts

index c8d4551167d28d0bcf64cf3e7afb082dff53841d..b72d8cbcb4c3354294dda16718a6d229e64d04e0 100644 (file)
@@ -1224,7 +1224,6 @@ export abstract class AbstractPool<
       this.emitter?.emit(PoolEvents.error, error)
       if (
         this.started &&
-        !this.starting &&
         !this.destroying &&
         this.opts.restartWorkerOnError === true
       ) {
@@ -1234,7 +1233,11 @@ export abstract class AbstractPool<
           this.createAndSetupWorkerNode()
         }
       }
-      if (this.started && this.opts.enableTasksQueue === true) {
+      if (
+        this.started &&
+        !this.destroying &&
+        this.opts.enableTasksQueue === true
+      ) {
         this.redistributeQueuedTasks(this.workerNodes.indexOf(workerNode))
       }
       workerNode?.terminate().catch(error => {