From 369179f64c3ff184193bde82102acb22e61ffb78 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Thu, 22 Feb 2024 20:59:14 +0100 Subject: [PATCH] fix: fix null exception regression MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit closes #1496 Signed-off-by: Jérôme Benoit --- CHANGELOG.md | 4 ++++ src/pools/abstract-pool.ts | 3 +-- src/pools/cluster/fixed.ts | 2 +- src/pools/thread/fixed.ts | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 002a8833..894f7c63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- Fix null exception regression: [#1496](https://github.com/poolifier/poolifier/issues/1496). + ## [3.1.20] - 2024-02-11 ### Fixed diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index bc77874f..6c73f43a 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -1564,8 +1564,7 @@ export abstract class AbstractPool< ) { workerInfo.stealing = false // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - for (const taskName of this.workerNodes[workerNodeKey].info - .taskFunctionNames!) { + for (const taskName of workerInfo.taskFunctionNames!) { this.resetTaskSequentiallyStolenStatisticsTaskFunctionWorkerUsage( workerNodeKey, taskName diff --git a/src/pools/cluster/fixed.ts b/src/pools/cluster/fixed.ts index c60266e3..1fea176c 100644 --- a/src/pools/cluster/fixed.ts +++ b/src/pools/cluster/fixed.ts @@ -52,7 +52,7 @@ export class FixedClusterPool< workerNodeKey: number, message: MessageValue ): void { - this.workerNodes[workerNodeKey].worker.send({ + this.workerNodes[workerNodeKey]?.worker.send({ ...message, workerId: this.getWorkerInfo(workerNodeKey)?.id } satisfies MessageValue) diff --git a/src/pools/thread/fixed.ts b/src/pools/thread/fixed.ts index d22d75fb..38dee9f0 100644 --- a/src/pools/thread/fixed.ts +++ b/src/pools/thread/fixed.ts @@ -52,7 +52,7 @@ export class FixedThreadPool< message: MessageValue, transferList?: TransferListItem[] ): void { - this.workerNodes[workerNodeKey].messageChannel?.port1.postMessage( + this.workerNodes[workerNodeKey]?.messageChannel?.port1.postMessage( { ...message, workerId: this.getWorkerInfo(workerNodeKey)?.id -- 2.34.1