From b5e35651fcd8e38c0f41641e8dab5267b8aeeab2 Mon Sep 17 00:00:00 2001 From: Michael Auerswald Date: Fri, 18 Aug 2023 12:49:05 +0200 Subject: [PATCH 1/2] replace throw with warning --- packages/core/src/ActiveWorkflows.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/core/src/ActiveWorkflows.ts b/packages/core/src/ActiveWorkflows.ts index 66eb1a06611f5..7935dd8947cf3 100644 --- a/packages/core/src/ActiveWorkflows.ts +++ b/packages/core/src/ActiveWorkflows.ts @@ -200,9 +200,10 @@ export class ActiveWorkflows { 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; } const workflowData = this.workflowData[id]; From a6bf26260b515f3aa76d12ae2a520a8d2c55da65 Mon Sep 17 00:00:00 2001 From: Michael Auerswald Date: Fri, 18 Aug 2023 13:38:22 +0200 Subject: [PATCH 2/2] add return value --- packages/cli/src/ActiveWorkflowRunner.ts | 6 ++++-- packages/core/src/ActiveWorkflows.ts | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/cli/src/ActiveWorkflowRunner.ts b/packages/cli/src/ActiveWorkflowRunner.ts index f830becb538a7..af2d4d75aeec1 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 7935dd8947cf3..5218d2c885726 100644 --- a/packages/core/src/ActiveWorkflows.ts +++ b/packages/core/src/ActiveWorkflows.ts @@ -197,13 +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 Logger.warn( `The workflow with the id "${id}" is currently not active and can so not be removed`, ); - return; + return false; } const workflowData = this.workflowData[id]; @@ -245,5 +245,7 @@ export class ActiveWorkflows { } delete this.workflowData[id]; + + return true; } }