refactor: factor out worker communication channel closing
[poolifier.git] / src / pools / thread / fixed.ts
index e3a94b329d4cfcee6f05cd6e2f8ad06e555a6dfc..bef82826350d772c146656d4676f942923d33165 100644 (file)
@@ -58,9 +58,7 @@ export class FixedThreadPool<
   /** @inheritDoc */
   protected async destroyWorker (worker: Worker): Promise<void> {
     this.sendToWorker(worker, { kill: true, workerId: worker.threadId })
-    const workerInfo = this.getWorkerInfoByWorker(worker)
-    workerInfo.messageChannel?.port1.close()
-    workerInfo.messageChannel?.port2.close()
+    this.workerNodes[this.getWorkerNodeKey(worker)].closeChannel()
     await worker.terminate()
   }