- if (this.info.type === WorkerTypes.thread) {
- await this.worker.terminate?.()
- } else if (this.info.type === WorkerTypes.cluster) {
- this.registerOnceWorkerEventHandler('disconnect', () => {
- this.worker.kill?.()
- })
- this.worker.disconnect?.()
+ switch (this.info.type) {
+ case WorkerTypes.thread:
+ this.worker.unref?.()
+ await this.worker.terminate?.()
+ break
+ case WorkerTypes.cluster:
+ this.registerOnceWorkerEventHandler('disconnect', () => {
+ this.worker.kill?.()
+ })
+ this.worker.disconnect?.()
+ break