try {
await this.destroyWorkerNode(workerNodeKey)
} catch (error) {
- if (
- this.emitter != null &&
- this.emitter.listenerCount(PoolEvents.error) > 0
- ) {
- this.emitter.emit(PoolEvents.error, error)
- }
+ this.emitter?.emit(PoolEvents.error, error)
}
})
)
workerNode.registerOnceWorkerEventHandler('error', (error: Error) => {
workerNode.info.ready = false
this.emitter?.emit(PoolEvents.error, error)
- if (
- this.started &&
- !this.destroying &&
- this.opts.restartWorkerOnError === true
- ) {
- if (workerNode.info.dynamic) {
- this.createAndSetupDynamicWorkerNode()
- } else if (!this.startingMinimumNumberOfWorkers) {
- this.startMinimumNumberOfWorkers(true)
+ if (this.started && !this.destroying) {
+ if (this.opts.restartWorkerOnError === true) {
+ if (workerNode.info.dynamic) {
+ this.createAndSetupDynamicWorkerNode()
+ } else if (!this.startingMinimumNumberOfWorkers) {
+ this.startMinimumNumberOfWorkers(true)
+ }
+ }
+ if (this.opts.enableTasksQueue === true) {
+ this.redistributeQueuedTasks(this.workerNodes.indexOf(workerNode))
}
- }
- if (
- this.started &&
- !this.destroying &&
- this.opts.enableTasksQueue === true
- ) {
- this.redistributeQueuedTasks(this.workerNodes.indexOf(workerNode))
}
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, promise/no-promise-in-callback
workerNode?.terminate().catch((error: unknown) => {