From ab6e5700b536a70bdef6accd66fce91f5e45cd69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 30 Aug 2024 15:27:15 +0200 Subject: [PATCH] fix: handle properly small or zero `tasksStealingRatio` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/pools/abstract-pool.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index a46eb785..2e818a2a 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -1848,8 +1848,9 @@ export abstract class AbstractPool< if ( !workerNode.info.continuousStealing && (this.cannotStealTask() || + this.opts.tasksQueueOptions?.tasksStealingRatio === 0 || (this.info.stealingWorkerNodes ?? 0) > - Math.round( + Math.ceil( this.workerNodes.length * this.opts.tasksQueueOptions!.tasksStealingRatio!, )) @@ -1913,8 +1914,9 @@ export abstract class AbstractPool< if ( this.cannotStealTask() || this.backPressure || + this.opts.tasksQueueOptions?.tasksStealingRatio === 0 || (this.info.stealingWorkerNodes ?? 0) > - Math.round( + Math.ceil( this.workerNodes.length * this.opts.tasksQueueOptions!.tasksStealingRatio!, )