resolve()
})
})
+ worker.unref()
await worker.terminate()
await waitWorkerExit
}
this.emitter?.emit(WorkerSetEvents.stopped, this.info)
- this.emitter?.emitDestroy()
- this.emitter?.removeAllListeners()
this.started = false
+ this.emitter?.emitDestroy()
}
/** @inheritDoc */
++workerSetElement.numberOfWorkerElements
// Add element sequentially to optimize memory at startup
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- if (this.workerOptions.elementStartDelay! > 0) {
+ if (this.workerOptions.elementAddDelay! > 0) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- await sleep(randomizeDelay(this.workerOptions.elementStartDelay!))
+ await sleep(randomizeDelay(this.workerOptions.elementAddDelay!))
}
}
) {
this.addWorkerSetElement()
}
+ worker.unref()
+ worker.terminate().catch((error: unknown) => this.emitter?.emit(WorkerSetEvents.error, error))
})
worker.on('online', this.workerOptions.poolOptions?.onlineHandler ?? EMPTY_FUNCTION)
worker.on('exit', this.workerOptions.poolOptions?.exitHandler ?? EMPTY_FUNCTION)