fix(editor): Recover from unsaved finished execution (#5121)

* 🐛 Recover from unsaved fixed execution

* 🔥 Remove logging

* ✏️ Use i18n
This commit is contained in:
Iván Ovejero 2023-01-11 10:52:32 +01:00 committed by GitHub
parent 819c4adb3c
commit af55ecd64b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 2 deletions

View file

@ -544,6 +544,11 @@ export interface IPushDataExecutionFinished {
retryOf?: string;
}
export interface IPushDataUnsavedExecutionFinished {
executionId: string;
data: { finished: true; stoppedAt: Date };
}
export interface IPushDataExecutionStarted {
executionId: string;
}

View file

@ -820,6 +820,8 @@
"nodeView.showMessage.keyDown.title": "Workflow created",
"nodeView.showMessage.showMaxNodeTypeError.message": "Only one '{nodeTypeDataDisplayName}' node is allowed in a workflow | Only {count} '{nodeTypeDataDisplayName}' nodes are allowed in a workflow",
"nodeView.showMessage.showMaxNodeTypeError.title": "Could not insert node",
"nodeView.showMessage.stopExecutionCatch.unsaved.message": "This execution was canceled",
"nodeView.showMessage.stopExecutionCatch.unsaved.title": "Execution canceled",
"nodeView.showMessage.stopExecutionCatch.message": "It completed before it could be stopped",
"nodeView.showMessage.stopExecutionCatch.title": "Workflow finished executing",
"nodeView.showMessage.stopExecutionTry.title": "Execution stopped",

View file

@ -15,6 +15,7 @@ import {
INodeUpdatePropertiesInformation,
IPushDataExecutionFinished,
IPushDataNodeExecuteAfter,
IPushDataUnsavedExecutionFinished,
IUpdateInformation,
IUsedCredential,
IWorkflowDb,
@ -886,7 +887,9 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, {
}
this.activeExecutions.unshift(newActiveExecution);
},
finishActiveExecution(finishedActiveExecution: IPushDataExecutionFinished): void {
finishActiveExecution(
finishedActiveExecution: IPushDataExecutionFinished | IPushDataUnsavedExecutionFinished,
): void {
// Find the execution to set to finished
const activeExecution = this.activeExecutions.find((execution) => {
return execution.id === finishedActiveExecution.executionId;

View file

@ -1383,7 +1383,28 @@ export default mixins(
} catch (error) {
// Execution stop might fail when the execution has already finished. Let's treat this here.
const execution = await this.restApi().getExecution(executionId);
if (execution?.finished) {
if (execution === undefined) {
// execution finished but was not saved (e.g. due to low connectivity)
this.workflowsStore.finishActiveExecution({
executionId,
data: { finished: true, stoppedAt: new Date() },
});
this.workflowsStore.executingNode = null;
this.uiStore.removeActiveAction('workflowRunning');
this.$titleSet(this.workflowsStore.workflowName, 'IDLE');
this.$showMessage({
title: this.$locale.baseText('nodeView.showMessage.stopExecutionCatch.unsaved.title'),
message: this.$locale.baseText(
'nodeView.showMessage.stopExecutionCatch.unsaved.message',
),
type: 'success',
});
} else if (execution?.finished) {
// execution finished before it could be stopped
const executedData = {
data: execution.data,
finished: execution.finished,