From 14454243e7e0b40fc766cdb05c6b34756fb59109 Mon Sep 17 00:00:00 2001 From: Mutasem Aldmour <4711238+mutdmour@users.noreply.github.com> Date: Fri, 13 Jan 2023 12:33:42 +0100 Subject: [PATCH] fix: Handle memory issues gracefully (#5147) * fix: add lost connection error * fix: stop exec, open in new tab * fix: only hosw if error failed * fix: fix typo * chore: eslint issue --- .../editor-ui/src/mixins/pushConnection.ts | 20 +++++++++++++++++++ .../src/plugins/i18n/locales/en.json | 2 ++ 2 files changed, 22 insertions(+) diff --git a/packages/editor-ui/src/mixins/pushConnection.ts b/packages/editor-ui/src/mixins/pushConnection.ts index 41b2aefdc..14971d104 100644 --- a/packages/editor-ui/src/mixins/pushConnection.ts +++ b/packages/editor-ui/src/mixins/pushConnection.ts @@ -38,6 +38,8 @@ export const pushConnection = mixins( reconnectTimeout: null as NodeJS.Timeout | null, retryTimeout: null as NodeJS.Timeout | null, pushMessageQueue: [] as Array<{ event: Event; retriesLeft: number }>, + connectRetries: 0, + lostConnection: false, }; }, computed: { @@ -53,6 +55,21 @@ export const pushConnection = mixins( } this.reconnectTimeout = setTimeout(() => { + this.connectRetries++; + const isWorkflowRunning = this.uiStore.isActionActive('workflowRunning'); + if (this.connectRetries > 3 && !this.lostConnection && isWorkflowRunning) { + this.lostConnection = true; + + this.workflowsStore.executingNode = null; + this.uiStore.removeActiveAction('workflowRunning'); + + this.$showMessage({ + title: this.$locale.baseText('pushConnection.executionFailed'), + message: this.$locale.baseText('pushConnection.executionFailed.message'), + type: 'error', + duration: 0, + }); + } this.pushConnect(); }, 3000); }, @@ -73,6 +90,9 @@ export const pushConnection = mixins( this.eventSource.addEventListener( 'open', () => { + this.connectRetries = 0; + this.lostConnection = false; + this.rootStore.pushConnectionActive = true; if (this.reconnectTimeout !== null) { clearTimeout(this.reconnectTimeout); diff --git a/packages/editor-ui/src/plugins/i18n/locales/en.json b/packages/editor-ui/src/plugins/i18n/locales/en.json index ae73814ae..47e87aeef 100644 --- a/packages/editor-ui/src/plugins/i18n/locales/en.json +++ b/packages/editor-ui/src/plugins/i18n/locales/en.json @@ -955,6 +955,8 @@ "pushConnectionTracker.connectionLost": "Connection lost", "pushConnection.pollingNode.dataNotFound": "No {service} data found", "pushConnection.pollingNode.dataNotFound.message": "We didn’t find any data in {service} to simulate an event. Please create one in {service} and try again.", + "pushConnection.executionFailed": "Execution failed", + "pushConnection.executionFailed.message": "There might not be enough memory to finish execution. Tips for avoiding this here", "resourceLocator.id.placeholder": "Enter ID...", "resourceLocator.mode.id": "By ID", "resourceLocator.mode.url": "By URL",