From: Jérôme Benoit Date: Thu, 22 Feb 2024 19:59:14 +0000 (+0100) Subject: fix: fix null exception regression X-Git-Tag: v3.1.21~2 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=369179f64c3ff184193bde82102acb22e61ffb78;p=poolifier.git fix: fix null exception regression closes #1496 Signed-off-by: Jérôme Benoit --- 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