fix(core): Fix canceled execution status (#6142)

This commit is contained in:
Michael Auerswald 2023-05-02 10:37:35 +02:00 committed by GitHub
parent 06fa6f1fb3
commit 839a56a682
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 3 deletions

View file

@ -290,6 +290,10 @@ export class InternalHooks implements IInternalHooksClass {
properties.user_id = userId; properties.user_id = userId;
} }
if (runData?.data.resultData.error?.message?.includes('canceled')) {
runData.status = 'canceled';
}
properties.success = !!runData?.finished; properties.success = !!runData?.finished;
let executionStatus: ExecutionStatus; let executionStatus: ExecutionStatus;
@ -297,6 +301,8 @@ export class InternalHooks implements IInternalHooksClass {
executionStatus = 'crashed'; executionStatus = 'crashed';
} else if (runData?.status === 'waiting' || runData?.data?.waitTill) { } else if (runData?.status === 'waiting' || runData?.data?.waitTill) {
executionStatus = 'waiting'; executionStatus = 'waiting';
} else if (runData?.status === 'canceled') {
executionStatus = 'canceled';
} else { } else {
executionStatus = properties.success ? 'success' : 'failed'; executionStatus = properties.success ? 'success' : 'failed';
} }

View file

@ -583,9 +583,12 @@ function hookFunctionsSave(parentProcessMode?: string): IWorkflowExecuteHooks {
} }
const workflowHasCrashed = fullRunData.status === 'crashed'; 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'; let workflowStatusFinal: ExecutionStatus = workflowDidSucceed ? 'success' : 'failed';
if (workflowHasCrashed) workflowStatusFinal = 'crashed'; if (workflowHasCrashed) workflowStatusFinal = 'crashed';
if (workflowWasCanceled) workflowStatusFinal = 'canceled';
if ( if (
(workflowDidSucceed && saveDataSuccessExecution === 'none') || (workflowDidSucceed && saveDataSuccessExecution === 'none') ||
@ -755,9 +758,12 @@ function hookFunctionsSaveWorker(): IWorkflowExecuteHooks {
} }
const workflowHasCrashed = fullRunData.status === 'crashed'; 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'; let workflowStatusFinal: ExecutionStatus = workflowDidSucceed ? 'success' : 'failed';
if (workflowHasCrashed) workflowStatusFinal = 'crashed'; if (workflowHasCrashed) workflowStatusFinal = 'crashed';
if (workflowWasCanceled) workflowStatusFinal = 'canceled';
if (!workflowDidSucceed) { if (!workflowDidSucceed) {
executeErrorWorkflow( executeErrorWorkflow(

View file

@ -472,6 +472,8 @@ process.on('message', async (message: IProcessMessage) => {
? new WorkflowOperationError('Workflow execution timed out!') ? new WorkflowOperationError('Workflow execution timed out!')
: new WorkflowOperationError('Workflow-Execution has been canceled!'); : 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 // If there is any data send it to parent process, if execution timedout add the error
await workflowRunner.workflowExecute.processSuccessExecution( await workflowRunner.workflowExecute.processSuccessExecution(
workflowRunner.startedAt, workflowRunner.startedAt,

View file

@ -1286,12 +1286,16 @@ export class WorkflowExecute {
message: executionError.message, message: executionError.message,
stack: executionError.stack, stack: executionError.stack,
} as ExecutionError; } as ExecutionError;
if (executionError.message?.includes('canceled')) {
fullRunData.status = 'canceled';
}
} else if (this.runExecutionData.waitTill!) { } else if (this.runExecutionData.waitTill!) {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
Logger.verbose(`Workflow execution will wait until ${this.runExecutionData.waitTill}`, { Logger.verbose(`Workflow execution will wait until ${this.runExecutionData.waitTill}`, {
workflowId: workflow.id, workflowId: workflow.id,
}); });
fullRunData.waitTill = this.runExecutionData.waitTill; fullRunData.waitTill = this.runExecutionData.waitTill;
fullRunData.status = 'waiting';
} else { } else {
Logger.verbose('Workflow execution finished successfully', { workflowId: workflow.id }); Logger.verbose('Workflow execution finished successfully', { workflowId: workflow.id });
fullRunData.finished = true; fullRunData.finished = true;
@ -1304,7 +1308,6 @@ export class WorkflowExecute {
// Static data of workflow changed // Static data of workflow changed
newStaticData = workflow.staticData; newStaticData = workflow.staticData;
} }
await this.executeHook('workflowExecuteAfter', [fullRunData, newStaticData]); await this.executeHook('workflowExecuteAfter', [fullRunData, newStaticData]);
if (closeFunction) { if (closeFunction) {