refactor: cleanup task redistribution code
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Sun, 3 Sep 2023 20:05:39 +0000 (22:05 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Sun, 3 Sep 2023 20:05:39 +0000 (22:05 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
src/pools/abstract-pool.ts

index aae083953c526c16f7bcaa92bddd3bf042423d3e..7933b54437a439d80547a52f57a137d51fc7eb83 100644 (file)
@@ -1203,11 +1203,9 @@ export abstract class AbstractPool<
     while (this.tasksQueueSize(workerNodeKey) > 0) {
       const destinationWorkerNodeKey = this.workerNodes.reduce(
         (minWorkerNodeKey, workerNode, workerNodeKey, workerNodes) => {
-          if (!workerNode.info.ready) {
-            return minWorkerNodeKey
-          }
-          return workerNode.usage.tasks.queued <
-            workerNodes[minWorkerNodeKey].usage.tasks.queued
+          return workerNode.info.ready &&
+            workerNode.usage.tasks.queued <
+              workerNodes[minWorkerNodeKey].usage.tasks.queued
             ? workerNodeKey
             : minWorkerNodeKey
         },