Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): Fix canceled execution status #6142

Merged
merged 2 commits into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/cli/src/InternalHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,13 +290,19 @@ export class InternalHooks implements IInternalHooksClass {
properties.user_id = userId;
}

if (runData?.data.resultData.error?.message?.includes('canceled')) {
runData.status = 'canceled';
}

properties.success = !!runData?.finished;

let executionStatus: ExecutionStatus;
if (runData?.status === 'crashed') {
executionStatus = 'crashed';
} else if (runData?.status === 'waiting' || runData?.data?.waitTill) {
executionStatus = 'waiting';
} else if (runData?.status === 'canceled') {
executionStatus = 'canceled';
} else {
executionStatus = properties.success ? 'success' : 'failed';
}
Expand Down
10 changes: 8 additions & 2 deletions packages/cli/src/WorkflowExecuteAdditionalData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -583,9 +583,12 @@ function hookFunctionsSave(parentProcessMode?: string): IWorkflowExecuteHooks {
}

const workflowHasCrashed = fullRunData.status === 'crashed';
const workflowDidSucceed = !fullRunData.data.resultData.error && !workflowHasCrashed;
const workflowWasCanceled = fullRunData.status === 'canceled';
const workflowDidSucceed =
!fullRunData.data.resultData.error && !workflowHasCrashed && !workflowWasCanceled;
let workflowStatusFinal: ExecutionStatus = workflowDidSucceed ? 'success' : 'failed';
if (workflowHasCrashed) workflowStatusFinal = 'crashed';
if (workflowWasCanceled) workflowStatusFinal = 'canceled';

if (
(workflowDidSucceed && saveDataSuccessExecution === 'none') ||
Expand Down Expand Up @@ -755,9 +758,12 @@ function hookFunctionsSaveWorker(): IWorkflowExecuteHooks {
}

const workflowHasCrashed = fullRunData.status === 'crashed';
const workflowDidSucceed = !fullRunData.data.resultData.error && !workflowHasCrashed;
const workflowWasCanceled = fullRunData.status === 'canceled';
const workflowDidSucceed =
!fullRunData.data.resultData.error && !workflowHasCrashed && !workflowWasCanceled;
let workflowStatusFinal: ExecutionStatus = workflowDidSucceed ? 'success' : 'failed';
if (workflowHasCrashed) workflowStatusFinal = 'crashed';
if (workflowWasCanceled) workflowStatusFinal = 'canceled';

if (!workflowDidSucceed) {
executeErrorWorkflow(
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/src/WorkflowRunnerProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,8 @@ process.on('message', async (message: IProcessMessage) => {
? new WorkflowOperationError('Workflow execution timed out!')
: new WorkflowOperationError('Workflow-Execution has been canceled!');

runData.status = message.type === 'timeout' ? 'failed' : 'canceled';

// If there is any data send it to parent process, if execution timedout add the error
await workflowRunner.workflowExecute.processSuccessExecution(
workflowRunner.startedAt,
Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/WorkflowExecute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1286,12 +1286,16 @@ export class WorkflowExecute {
message: executionError.message,
stack: executionError.stack,
} as ExecutionError;
if (executionError.message?.includes('canceled')) {
fullRunData.status = 'canceled';
}
} else if (this.runExecutionData.waitTill!) {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
Logger.verbose(`Workflow execution will wait until ${this.runExecutionData.waitTill}`, {
workflowId: workflow.id,
});
fullRunData.waitTill = this.runExecutionData.waitTill;
fullRunData.status = 'waiting';
} else {
Logger.verbose('Workflow execution finished successfully', { workflowId: workflow.id });
fullRunData.finished = true;
Expand All @@ -1304,7 +1308,6 @@ export class WorkflowExecute {
// Static data of workflow changed
newStaticData = workflow.staticData;
}

await this.executeHook('workflowExecuteAfter', [fullRunData, newStaticData]);

if (closeFunction) {
Expand Down