refactor: cleanup cluster ESM issue workaround
[poolifier.git] / src / pools / worker-node.ts
index 2c39393b05eb416b16f7aba82cdba417ab5b4758..3b69d3854e07015aa0019ee84f164b8569ffe9aa 100644 (file)
@@ -74,6 +74,17 @@ implements IWorkerNode<Worker, Data> {
     this.tasksUsage.clear()
   }
 
+  /** @inheritdoc */
+  public closeChannel (): void {
+    if (this.info.messageChannel != null) {
+      this.info.messageChannel?.port1.unref()
+      this.info.messageChannel?.port2.unref()
+      this.info.messageChannel?.port1.close()
+      this.info.messageChannel?.port2.close()
+      delete this.info.messageChannel
+    }
+  }
+
   /** @inheritdoc */
   public getTaskWorkerUsage (name: string): WorkerUsage | undefined {
     if (!this.tasksUsage.has(name)) {