From 1d90cd3b0910a0ea9fe3d85175f2c63d9123c40a Mon Sep 17 00:00:00 2001 From: Jan Oberhauser Date: Thu, 7 Oct 2021 13:53:45 -0500 Subject: [PATCH] :bug: Fix that active executions could not be canceled in main mode --- packages/core/src/WorkflowExecute.ts | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/packages/core/src/WorkflowExecute.ts b/packages/core/src/WorkflowExecute.ts index 65361586fe..4593f90664 100644 --- a/packages/core/src/WorkflowExecute.ts +++ b/packages/core/src/WorkflowExecute.ts @@ -74,8 +74,11 @@ export class WorkflowExecute { * @returns {(Promise)} * @memberof WorkflowExecute */ - // @ts-ignore - async run(workflow: Workflow, startNode?: INode, destinationNode?: string): PCancelable { + // IMPORTANT: Do not add "async" to this function, it will then convert the + // PCancelable to a regular Promise and does so not allow canceling + // active executions anymore + // eslint-disable-next-line @typescript-eslint/promise-function-async + run(workflow: Workflow, startNode?: INode, destinationNode?: string): PCancelable { // Get the nodes to start workflow execution from startNode = startNode || workflow.getStartNode(destinationNode); @@ -134,8 +137,11 @@ export class WorkflowExecute { * @returns {(Promise)} * @memberof WorkflowExecute */ - // @ts-ignore - async runPartialWorkflow( + // IMPORTANT: Do not add "async" to this function, it will then convert the + // PCancelable to a regular Promise and does so not allow canceling + // active executions anymore + // eslint-disable-next-line @typescript-eslint/promise-function-async + runPartialWorkflow( workflow: Workflow, runData: IRunData, startNodes: string[], @@ -576,8 +582,11 @@ export class WorkflowExecute { * @returns {Promise} * @memberof WorkflowExecute */ - // @ts-ignore - async processRunExecutionData(workflow: Workflow): PCancelable { + // IMPORTANT: Do not add "async" to this function, it will then convert the + // PCancelable to a regular Promise and does so not allow canceling + // active executions anymore + // eslint-disable-next-line @typescript-eslint/promise-function-async + processRunExecutionData(workflow: Workflow): PCancelable { Logger.verbose('Workflow execution started', { workflowId: workflow.id }); const startedAt = new Date(); @@ -1063,8 +1072,7 @@ export class WorkflowExecute { startedAt: Date, workflow: Workflow, executionError?: ExecutionError, - // @ts-ignore - ): PCancelable { + ): Promise { const fullRunData = this.getFullRunData(startedAt); if (executionError !== undefined) {