Skip to content

Commit

Permalink
fix(editor): Recover from unsaved finished execution (#5121)
Browse files Browse the repository at this point in the history
* 🐛 Recover from unsaved fixed execution

* 🔥 Remove logging

* ✏️ Use i18n
  • Loading branch information
ivov authored Jan 11, 2023
1 parent 819c4ad commit af55ecd
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
5 changes: 5 additions & 0 deletions packages/editor-ui/src/Interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,11 @@ export interface IPushDataExecutionFinished {
retryOf?: string;
}

export interface IPushDataUnsavedExecutionFinished {
executionId: string;
data: { finished: true; stoppedAt: Date };
}

export interface IPushDataExecutionStarted {
executionId: string;
}
Expand Down
2 changes: 2 additions & 0 deletions packages/editor-ui/src/plugins/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion packages/editor-ui/src/stores/workflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
INodeUpdatePropertiesInformation,
IPushDataExecutionFinished,
IPushDataNodeExecuteAfter,
IPushDataUnsavedExecutionFinished,
IUpdateInformation,
IUsedCredential,
IWorkflowDb,
Expand Down Expand Up @@ -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;
Expand Down
23 changes: 22 additions & 1 deletion packages/editor-ui/src/views/NodeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit af55ecd

Please sign in to comment.