mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
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:
parent
2881ee9ecc
commit
3e382ef85e
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -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(
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue