perf: optimize pool shutdown
authorJérôme Benoit <jerome.benoit@sap.com>
Mon, 10 Apr 2023 03:59:53 +0000 (05:59 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Mon, 10 Apr 2023 03:59:53 +0000 (05:59 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/pools/abstract-pool.ts

index 6548eba30189c2491bc244eb6e7e168b395b14f0..661eb7b6ec363c228ad0c540f43b44361b76e75e 100644 (file)
@@ -258,8 +258,8 @@ export abstract class AbstractPool<
   /** @inheritDoc */
   public async destroy (): Promise<void> {
     await Promise.all(
-      this.workerNodes.map(async workerNode => {
-        this.flushTasksQueueByWorker(workerNode.worker)
+      this.workerNodes.map(async (workerNode, workerNodeKey) => {
+        this.flushTasksQueue(workerNodeKey)
         await this.destroyWorker(workerNode.worker)
       })
     )