build(ci): cleanup workflows
[poolifier.git] / src / pools / abstract-pool.ts
index e61711a8843228e6d4a91724ea00fdf6b4ad8ca4..cbc24e7d84c65c3313f0e27aea9f927ea7bfe543 100644 (file)
@@ -668,6 +668,20 @@ export abstract class AbstractPool<
     }
   }
 
+  private buildTasksQueueOptions (
+    tasksQueueOptions: TasksQueueOptions
+  ): TasksQueueOptions {
+    return {
+      ...{
+        size: Math.pow(this.maxSize, 2),
+        concurrency: 1,
+        taskStealing: true,
+        tasksStealingOnBackPressure: true
+      },
+      ...tasksQueueOptions
+    }
+  }
+
   private setTasksQueueSize (size: number): void {
     for (const workerNode of this.workerNodes) {
       workerNode.tasksQueueBackPressureSize = size
@@ -700,20 +714,6 @@ export abstract class AbstractPool<
     }
   }
 
-  private buildTasksQueueOptions (
-    tasksQueueOptions: TasksQueueOptions
-  ): TasksQueueOptions {
-    return {
-      ...{
-        size: Math.pow(this.maxSize, 2),
-        concurrency: 1,
-        taskStealing: true,
-        tasksStealingOnBackPressure: true
-      },
-      ...tasksQueueOptions
-    }
-  }
-
   /**
    * Whether the pool is full or not.
    *
@@ -1118,9 +1118,9 @@ export abstract class AbstractPool<
       this.workerNodes[workerNodeKey].closeChannel()
       this.emitter?.emit(PoolEvents.error, error)
       if (
-        this.opts.restartWorkerOnError === true &&
         this.started &&
-        !this.starting
+        !this.starting &&
+        this.opts.restartWorkerOnError === true
       ) {
         if (workerInfo.dynamic) {
           this.createAndSetupDynamicWorkerNode()
@@ -1128,7 +1128,7 @@ export abstract class AbstractPool<
           this.createAndSetupWorkerNode()
         }
       }
-      if (this.opts.enableTasksQueue === true) {
+      if (this.started && this.opts.enableTasksQueue === true) {
         this.redistributeQueuedTasks(workerNodeKey)
       }
     })
@@ -1396,8 +1396,8 @@ export abstract class AbstractPool<
     )
     workerInfo.ready = message.ready as boolean
     workerInfo.taskFunctions = message.taskFunctions
-    if (this.emitter != null && this.ready) {
-      this.emitter.emit(PoolEvents.ready, this.info)
+    if (this.ready) {
+      this.emitter?.emit(PoolEvents.ready, this.info)
     }
   }