fix: ensure worker graceful shutdown is tried in cluster pool
authorJérôme Benoit <jerome.benoit@sap.com>
Wed, 21 Jun 2023 23:28:38 +0000 (01:28 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Wed, 21 Jun 2023 23:28:38 +0000 (01:28 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/pools/cluster/fixed.ts

index a13a95ceea7aed2a01c98a4f8641408ad2c38741..3f56c858b0ed5b363fc19da06eb1b9a295a66dd5 100644 (file)
@@ -69,7 +69,10 @@ export class FixedClusterPool<
   /** @inheritDoc */
   protected destroyWorker (worker: Worker): void {
     this.sendToWorker(worker, { kill: 1 })
-    worker.kill()
+    worker.on('disconnect', () => {
+      worker.kill()
+    })
+    worker.disconnect()
   }
 
   /** @inheritDoc */