fix: emit error event if a dynamic worker destroy fails
authorJérôme Benoit <jerome.benoit@sap.com>
Mon, 14 Aug 2023 20:25:51 +0000 (22:25 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Mon, 14 Aug 2023 20:25:51 +0000 (22:25 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/pools/abstract-pool.ts

index f76ad2f55bf4326383077456d7414aa8c023ea2e..2a52d5486984133e620552877e90921d50d96190 100644 (file)
@@ -958,7 +958,9 @@ export abstract class AbstractPool<
               workerUsage.tasks.executing === 0 &&
               this.tasksQueueSize(localWorkerNodeKey) === 0)))
       ) {
-        this.destroyWorkerNode(localWorkerNodeKey).catch(EMPTY_FUNCTION)
+        this.destroyWorkerNode(localWorkerNodeKey).catch((error) => {
+          this.emitter?.emit(PoolEvents.error, error)
+        })
       }
     })
     const workerInfo = this.getWorkerInfo(workerNodeKey)