fix(core): Fix issue where sub workflows would display as running forever after failure to start (#5905)

* fixed recovery / status for early return in main mode

* mark non-data returning executions in own mode as failed

* improve error handling
This commit is contained in:
Michael Auerswald 2023-04-06 11:36:11 +02:00 committed by GitHub
parent 2881ee9ecc
commit 3e382ef85e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 7 deletions

View file

@ -638,7 +638,7 @@ function hookFunctionsSave(parentProcessMode?: string): IWorkflowExecuteHooks {
};
if (this.retryOf !== undefined) {
fullExecutionData.retryOf = this.retryOf.toString();
fullExecutionData.retryOf = this.retryOf?.toString();
}
const workflowId = this.workflowData.id;
@ -1054,7 +1054,7 @@ async function executeWorkflow(
mode: 'integrated',
startedAt: new Date(),
stoppedAt: new Date(),
status: 'error',
status: 'failed',
};
// When failing, we might not have finished the execution
// Therefore, database might not contain finished errors.
@ -1073,6 +1073,9 @@ async function executeWorkflow(
fullExecutionData.workflowId = workflowData.id;
}
// remove execution from active executions
Container.get(ActiveExecutions).remove(executionId, fullRunData);
const executionData = ResponseHelper.flattenExecutionData(fullExecutionData);
await Db.collections.Execution.update(executionId, executionData as IExecutionFlattedDb);

View file

@ -744,8 +744,22 @@ export class WorkflowRunner {
childExecutionIds.splice(executionIdIndex, 1);
}
// eslint-disable-next-line @typescript-eslint/await-thenable
this.activeExecutions.remove(message.data.executionId, message.data.result);
if (message.data.result === undefined) {
const noDataError = new WorkflowOperationError('Workflow finished with no result data');
const subWorkflowHooks = WorkflowExecuteAdditionalData.getWorkflowHooksMain(
data,
message.data.executionId,
);
await this.processError(
noDataError,
startedAt,
data.executionMode,
message.data?.executionId,
subWorkflowHooks,
);
} else {
this.activeExecutions.remove(message.data.executionId, message.data.result);
}
}
});

View file

@ -155,9 +155,10 @@ export async function recoverExecutionDataFromEventLogMessages(
}
if (applyToDb) {
const newStatus = executionEntry.status === 'failed' ? 'failed' : 'crashed';
await Db.collections.Execution.update(executionId, {
data: stringify(executionData),
status: 'crashed',
status: newStatus,
stoppedAt: lastNodeRunTimestamp?.toJSDate(),
});
await Container.get(InternalHooks).onWorkflowPostExecute(
@ -170,7 +171,7 @@ export async function recoverExecutionDataFromEventLogMessages(
waitTill: executionEntry.waitTill ?? undefined,
startedAt: executionEntry.startedAt,
stoppedAt: lastNodeRunTimestamp?.toJSDate(),
status: 'crashed',
status: newStatus,
},
);
const iRunData: IRun = {
@ -180,7 +181,7 @@ export async function recoverExecutionDataFromEventLogMessages(
waitTill: executionEntry.waitTill ?? undefined,
startedAt: executionEntry.startedAt,
stoppedAt: lastNodeRunTimestamp?.toJSDate(),
status: 'crashed',
status: newStatus,
};
const workflowHooks = getWorkflowHooksMain(
{