From: Jérôme Benoit Date: Thu, 9 May 2024 16:03:38 +0000 (+0200) Subject: fix: null expection in X-Git-Tag: v4.0.5~2 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=3b33cd2a86cd6f2e8beedcb03d9fddd421644e10;p=poolifier.git fix: null expection in updateTaskSequentiallyStolenStatisticsWorkerUsage() Signed-off-by: Jérôme Benoit --- diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index 10c99171..d65ac2ff 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -1671,23 +1671,23 @@ export abstract class AbstractPool< if (workerNode?.usage != null) { ++workerNode.usage.tasks.sequentiallyStolen } - const taskFunctionWorkerUsage = - workerNode.getTaskFunctionWorkerUsage(taskName) if ( this.shallUpdateTaskFunctionWorkerUsage(workerNodeKey) && - taskFunctionWorkerUsage != null && - (taskFunctionWorkerUsage.tasks.sequentiallyStolen === 0 || + workerNode.getTaskFunctionWorkerUsage(taskName) != null + ) { + const taskFunctionWorkerUsage = + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + workerNode.getTaskFunctionWorkerUsage(taskName)! + if ( + taskFunctionWorkerUsage.tasks.sequentiallyStolen === 0 || (previousTaskName != null && previousTaskName === taskName && - taskFunctionWorkerUsage.tasks.sequentiallyStolen > 0)) - ) { - ++taskFunctionWorkerUsage.tasks.sequentiallyStolen - } else if ( - this.shallUpdateTaskFunctionWorkerUsage(workerNodeKey) && - taskFunctionWorkerUsage != null && - taskFunctionWorkerUsage.tasks.sequentiallyStolen > 0 - ) { - taskFunctionWorkerUsage.tasks.sequentiallyStolen = 0 + taskFunctionWorkerUsage.tasks.sequentiallyStolen > 0) + ) { + ++taskFunctionWorkerUsage.tasks.sequentiallyStolen + } else if (taskFunctionWorkerUsage.tasks.sequentiallyStolen > 0) { + taskFunctionWorkerUsage.tasks.sequentiallyStolen = 0 + } } }