fix: fix null exception regression
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 22 Feb 2024 19:59:14 +0000 (20:59 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 22 Feb 2024 19:59:14 +0000 (20:59 +0100)
closes #1496

Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
CHANGELOG.md
src/pools/abstract-pool.ts
src/pools/cluster/fixed.ts
src/pools/thread/fixed.ts

index 002a88336b278c35152c52e6884053452349c3a1..894f7c63357664da8ae35eaf51399fe0170a74e2 100644 (file)
@@ -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
index bc77874ff423bb3ee112f6150db81962ae5d6e69..6c73f43a590933db50c3cab78a806eab526b2217 100644 (file)
@@ -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
index c60266e3d72b623fb9225dcc20882c064d29438c..1fea176c4f3884c1ce4778f891d059d9f48bbbde 100644 (file)
@@ -52,7 +52,7 @@ export class FixedClusterPool<
     workerNodeKey: number,
     message: MessageValue<Data>
   ): void {
-    this.workerNodes[workerNodeKey].worker.send({
+    this.workerNodes[workerNodeKey]?.worker.send({
       ...message,
       workerId: this.getWorkerInfo(workerNodeKey)?.id
     } satisfies MessageValue<Data>)
index d22d75fb3b5a397e8a2371a700d53d4f243160ba..38dee9f02605f21847bdd3bd0d5303f2824b4dcb 100644 (file)
@@ -52,7 +52,7 @@ export class FixedThreadPool<
     message: MessageValue<Data>,
     transferList?: TransferListItem[]
   ): void {
-    this.workerNodes[workerNodeKey].messageChannel?.port1.postMessage(
+    this.workerNodes[workerNodeKey]?.messageChannel?.port1.postMessage(
       {
         ...message,
         workerId: this.getWorkerInfo(workerNodeKey)?.id