From b6a00febbdd62560fa68321fbcd6e44c92a82ddd Mon Sep 17 00:00:00 2001 From: Michael Auerswald Date: Fri, 18 Aug 2023 14:04:49 +0200 Subject: [PATCH] fix(core): Replace throw with warning when deactivating a non-active workflow (#6969) Replaces a throw with a warning message instead, since the failure in question is not serious enough to warrant stopping the application. --- packages/cli/src/ActiveWorkflowRunner.ts | 6 ++++-- packages/core/src/ActiveWorkflows.ts | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/cli/src/ActiveWorkflowRunner.ts b/packages/cli/src/ActiveWorkflowRunner.ts index f830becb53..af2d4d75ae 100644 --- a/packages/cli/src/ActiveWorkflowRunner.ts +++ b/packages/cli/src/ActiveWorkflowRunner.ts @@ -920,8 +920,10 @@ export class ActiveWorkflowRunner implements IWebhookManager { // if it's active in memory then it's a trigger // so remove from list of actives workflows if (this.activeWorkflows.isActive(workflowId)) { - await this.activeWorkflows.remove(workflowId); - Logger.verbose(`Successfully deactivated workflow "${workflowId}"`, { workflowId }); + const removalSuccess = await this.activeWorkflows.remove(workflowId); + if (removalSuccess) { + Logger.verbose(`Successfully deactivated workflow "${workflowId}"`, { workflowId }); + } } } } diff --git a/packages/core/src/ActiveWorkflows.ts b/packages/core/src/ActiveWorkflows.ts index 66eb1a0661..5218d2c885 100644 --- a/packages/core/src/ActiveWorkflows.ts +++ b/packages/core/src/ActiveWorkflows.ts @@ -197,12 +197,13 @@ export class ActiveWorkflows { * * @param {string} id The id of the workflow to deactivate */ - async remove(id: string): Promise { + async remove(id: string): Promise { if (!this.isActive(id)) { // Workflow is currently not registered - throw new Error( + Logger.warn( `The workflow with the id "${id}" is currently not active and can so not be removed`, ); + return false; } const workflowData = this.workflowData[id]; @@ -244,5 +245,7 @@ export class ActiveWorkflows { } delete this.workflowData[id]; + + return true; } }