fix: do not add undefined task runtime to the history
authorJérôme Benoit <jerome.benoit@sap.com>
Mon, 8 May 2023 22:47:21 +0000 (00:47 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Mon, 8 May 2023 22:47:21 +0000 (00:47 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/pools/abstract-pool.ts

index eab110d8ec4d2200ec78320383874abbf333562a..b9a7cd398920fc77a754d3d4047414beae94ba46 100644 (file)
@@ -440,8 +440,11 @@ export abstract class AbstractPool<
         workerTasksUsage.avgRunTime =
           workerTasksUsage.runTime / workerTasksUsage.run
       }
-      if (this.workerChoiceStrategyContext.getRequiredStatistics().medRunTime) {
-        workerTasksUsage.runTimeHistory.push(message.runTime ?? 0)
+      if (
+        this.workerChoiceStrategyContext.getRequiredStatistics().medRunTime &&
+        message.runTime != null
+      ) {
+        workerTasksUsage.runTimeHistory.push(message.runTime)
         workerTasksUsage.medRunTime = median(workerTasksUsage.runTimeHistory)
       }
     }