refactor: cleanup queued tasks computation
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 25 Jun 2023 16:38:37 +0000 (18:38 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sun, 25 Jun 2023 16:38:37 +0000 (18:38 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/pools/abstract-pool.ts

index 07907be9c6c48bd6eaf73edad4144bba9ada8800..413a1fc0a1246372796230c1f084d0795fa85855 100644 (file)
@@ -911,15 +911,15 @@ export abstract class AbstractPool<
   }
 
   private getWorkerUsage (workerNodeKey?: number): WorkerUsage {
-    const getQueueSize = (workerNodeKey: number): number => {
-      return this.tasksQueueSize(workerNodeKey)
+    const getTasksQueueSize = (workerNodeKey?: number): number => {
+      return workerNodeKey != null ? this.tasksQueueSize(workerNodeKey) : 0
     }
     return {
       tasks: {
         executed: 0,
         executing: 0,
         get queued (): number {
-          return workerNodeKey == null ? 0 : getQueueSize(workerNodeKey)
+          return getTasksQueueSize(workerNodeKey)
         },
         failed: 0
       },