fix: fix task dequeuing from the last bucket
[poolifier.git] / src / pools / selection-strategies / fair-share-worker-choice-strategy.ts
index 2f2686e9bb0f5f6a6c18aa5ce51c913e9d3af7c5..d1a4919d70184950dcacdf4596db552579bc9fb1 100644 (file)
@@ -81,9 +81,6 @@ export class FairShareWorkerChoiceStrategy<
   }
 
   private fairShareNextWorkerNodeKey (): number | undefined {
-    if (this.pool.workerNodes.length === 0) {
-      return undefined
-    }
     return this.pool.workerNodes.reduce(
       (minWorkerNodeKey, workerNode, workerNodeKey, workerNodes) => {
         if (workerNode.strategyData?.virtualTaskEndTimestamp == null) {
@@ -139,7 +136,7 @@ export class FairShareWorkerChoiceStrategy<
       this.pool.workerNodes[workerNodeKey]?.strategyData
         ?.virtualTaskEndTimestamp
     const now = performance.now()
-    return now < (virtualTaskEndTimestamp ?? -Infinity)
+    return now < (virtualTaskEndTimestamp ?? Number.NEGATIVE_INFINITY)
       ? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
       virtualTaskEndTimestamp!
       : now