From 272b30e5460adc2fcadaab49fc187e9e14bbe89a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Grzywacz?= Date: Wed, 13 Mar 2024 10:47:25 +0100 Subject: [PATCH] feat: critical error event in task executor --- src/events.ts | 5 +++++ src/executor.ts | 1 + 2 files changed, 6 insertions(+) diff --git a/src/events.ts b/src/events.ts index d767efa..78bfea9 100644 --- a/src/events.ts +++ b/src/events.ts @@ -20,6 +20,11 @@ export interface TaskExecutorEventsDict { */ beforeEnd: (timestamp: number) => void; + /** + * Fires when task executor encountered an unrecoverable error and is about to shut down. + */ + criticalError: (err: Error) => void; + /** * Fires when task executor is completely terminated. */ diff --git a/src/executor.ts b/src/executor.ts index cb5e09c..8407fd4 100644 --- a/src/executor.ts +++ b/src/executor.ts @@ -472,6 +472,7 @@ export class TaskExecutor { } private handleCriticalError(err: Error) { + this.events.emit("criticalError", err); const message = "TaskExecutor faced a critical error and will now cancel work, terminate agreements and request settling payments"; this.logger.error(message, err);