From e45f62158cd1a0e899173a453b1fa43fb8ce7bba Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 30 Aug 2024 15:22:40 +0200 Subject: [PATCH] fix: handle properly small or zero `tasksStealingRatio` MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 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 daef9434..098ed233 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -240,8 +240,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 * // eslint-disable-next-line @typescript-eslint/no-non-null-assertion this.opts.tasksQueueOptions!.tasksStealingRatio! @@ -299,8 +300,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 * // eslint-disable-next-line @typescript-eslint/no-non-null-assertion this.opts.tasksQueueOptions!.tasksStealingRatio! -- 2.34.1