From 1910299a884e8d4d80d4aa6656eb4892b0fcb713 Mon Sep 17 00:00:00 2001 From: Jan Oberhauser Date: Fri, 27 May 2022 16:05:16 +0200 Subject: [PATCH] fix(core): Fix issue that "closeFunction" got called twice --- packages/cli/src/ActiveWorkflowRunner.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/cli/src/ActiveWorkflowRunner.ts b/packages/cli/src/ActiveWorkflowRunner.ts index 9c7af3609..70d8e117d 100644 --- a/packages/cli/src/ActiveWorkflowRunner.ts +++ b/packages/cli/src/ActiveWorkflowRunner.ts @@ -134,22 +134,24 @@ export class ActiveWorkflowRunner { * @memberof ActiveWorkflowRunner */ async removeAll(): Promise { - const activeWorkflowId: string[] = []; + let activeWorkflowIds: string[] = []; Logger.verbose('Call to remove all active workflows received (removeAll)'); if (this.activeWorkflows !== null) { - // TODO: This should be renamed! - activeWorkflowId.push.apply(activeWorkflowId, this.activeWorkflows.allActiveWorkflows()); + activeWorkflowIds.push.apply(activeWorkflowIds, this.activeWorkflows.allActiveWorkflows()); } const activeWorkflows = await this.getActiveWorkflows(); - activeWorkflowId.push.apply( - activeWorkflowId, - activeWorkflows.map((workflow) => workflow.id), - ); + activeWorkflowIds = [ + ...activeWorkflowIds, + ...activeWorkflows.map((workflow) => workflow.id.toString()), + ]; + + // Make sure IDs are unique + activeWorkflowIds = Array.from(new Set(activeWorkflowIds)); const removePromises = []; - for (const workflowId of activeWorkflowId) { + for (const workflowId of activeWorkflowIds) { removePromises.push(this.remove(workflowId)); }