## [Unreleased]
+### Fixed
+
+- Workaround possible race condition at work nodes array element removal and querying. See [issue #1468](https://github.com/poolifier/poolifier/issues/1468).
+
### Changed
- Switch the worker node eventing code to `EventTarget` API .
* @returns The worker information.
*/
protected getWorkerInfo (workerNodeKey: number): WorkerInfo {
- return this.workerNodes[workerNodeKey].info
+ return this.workerNodes[workerNodeKey]?.info
}
/**
): void {
this.workerNodes[workerNodeKey].worker.send({
...message,
- workerId: this.workerNodes[workerNodeKey].info.id as number
+ workerId: this.getWorkerInfo(workerNodeKey).id as number
})
}
* @returns Whether the worker node is ready or not.
*/
private isWorkerNodeReady (workerNodeKey: number): boolean {
- return this.pool.workerNodes[workerNodeKey].info.ready
+ return this.pool.workerNodes[workerNodeKey]?.info.ready
}
/**
(
this.workerNodes[workerNodeKey].messageChannel as MessageChannel
).port1.postMessage(
- { ...message, workerId: this.workerNodes[workerNodeKey].info.id },
+ { ...message, workerId: this.getWorkerInfo(workerNodeKey).id },
transferList
)
}
workerNode.worker.postMessage(
{
ready: false,
- workerId: workerNode.info.id,
+ workerId: this.getWorkerInfo(workerNodeKey).id,
port: port2
},
[port2]