Merge dependabot/npm_and_yarn/examples/typescript/http-server-pool/fastify-hybrid...
[poolifier.git] / src / pools / cluster / fixed.ts
index 3b45dc17e005f9495ea73a05c6abef478fccb2de..4a8cb4f1eeeafeb59adf1e30c5d678328cb19b70 100644 (file)
@@ -1,4 +1,5 @@
 import cluster, { type Worker } from 'node:cluster'
+
 import type { MessageValue } from '../../utility-types.js'
 import { AbstractPool } from '../abstract-pool.js'
 import { type PoolOptions, type PoolType, PoolTypes } from '../pool.js'
@@ -52,10 +53,10 @@ 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 as number
-    })
+      workerId: this.getWorkerInfo(workerNodeKey)?.id
+    } satisfies MessageValue<Data>)
   }
 
   /** @inheritDoc */