From 65e6d7c0f86134cbe9702d0c4155b11f778a8898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Wed, 30 Jun 2021 10:53:27 +0200 Subject: [PATCH] :zap: Add logging for pruning errors --- .../cli/src/WorkflowExecuteAdditionalData.ts | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/packages/cli/src/WorkflowExecuteAdditionalData.ts b/packages/cli/src/WorkflowExecuteAdditionalData.ts index 9d0478d997..a969dbc812 100644 --- a/packages/cli/src/WorkflowExecuteAdditionalData.ts +++ b/packages/cli/src/WorkflowExecuteAdditionalData.ts @@ -102,7 +102,7 @@ function executeErrorWorkflow(workflowData: IWorkflowBase, fullRunData: IRun, mo * */ let throttling = false; -function pruneExecutionData(): void { +function pruneExecutionData(this: WorkflowHooks): void { if (!throttling) { Logger.verbose('Pruning execution data from database'); @@ -118,7 +118,11 @@ function pruneExecutionData(): void { setTimeout(() => { throttling = false; }, timeout * 1000) - ).catch(err => throttling = false); + ).catch(error => { + throttling = false; + + Logger.error(`Failed pruning execution data from database for execution ID ${this.executionId} (hookFunctionsSave)`, { ...error, executionId: this.executionId, sessionId: this.sessionId, workflowId: this.workflowData.id }); + }); } } @@ -322,7 +326,7 @@ function hookFunctionsSave(parentProcessMode?: string): IWorkflowExecuteHooks { // Prune old execution data if (config.get('executions.pruneData')) { - pruneExecutionData(); + pruneExecutionData.call(this); } const isManualMode = [this.mode, parentProcessMode].includes('manual'); @@ -387,9 +391,9 @@ function hookFunctionsSave(parentProcessMode?: string): IWorkflowExecuteHooks { } // Leave log message before flatten as that operation increased memory usage a lot and the chance of a crash is highest here - Logger.debug(`Save execution data to database for execution ID ${this.executionId}`, { - executionId: this.executionId, - workflowId: this.workflowData.id, + Logger.debug(`Save execution data to database for execution ID ${this.executionId}`, { + executionId: this.executionId, + workflowId: this.workflowData.id, finished: fullExecutionData.finished, stoppedAt: fullExecutionData.stoppedAt, }); @@ -409,12 +413,12 @@ function hookFunctionsSave(parentProcessMode?: string): IWorkflowExecuteHooks { executeErrorWorkflow(this.workflowData, fullRunData, this.mode, this.executionId, this.retryOf); } } catch (error) { - Logger.error(`Failed saving execution data to DB on execution ID ${this.executionId}`, { - executionId: this.executionId, + Logger.error(`Failed saving execution data to DB on execution ID ${this.executionId}`, { + executionId: this.executionId, workflowId: this.workflowData.id, error, }); - + if (!isManualMode) { executeErrorWorkflow(this.workflowData, fullRunData, this.mode, undefined, this.retryOf); }