fix: fix task function queue size computation
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 20 Aug 2023 11:19:17 +0000 (13:19 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sun, 20 Aug 2023 11:19:17 +0000 (13:19 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/pools/worker-node.ts

index dbbfbe6727f73643037b0ec423b7feb6038f2bdc..82e276886c08f56bc4051bc537df88b222600af0 100644 (file)
@@ -190,25 +190,25 @@ implements IWorkerNode<Worker, Data> {
   }
 
   private initTaskFunctionWorkerUsage (name: string): WorkerUsage {
-    const getTaskQueueSize = (): number => {
-      let taskQueueSize = 0
+    const getTaskFunctionQueueSize = (): number => {
+      let taskFunctionQueueSize = 0
       for (const task of this.tasksQueue) {
         if (
-          (name === DEFAULT_TASK_NAME &&
-            task.name === (this.info.taskFunctions as string[])[1]) ||
-          task.name === name
+          (task.name === DEFAULT_TASK_NAME &&
+            name === (this.info.taskFunctions as string[])[1]) ||
+          (task.name !== DEFAULT_TASK_NAME && name === task.name)
         ) {
-          ++taskQueueSize
+          ++taskFunctionQueueSize
         }
       }
-      return taskQueueSize
+      return taskFunctionQueueSize
     }
     return {
       tasks: {
         executed: 0,
         executing: 0,
         get queued (): number {
-          return getTaskQueueSize()
+          return getTaskFunctionQueueSize()
         },
         failed: 0
       },