From a550093f3e268727cf0d841f8cabe599f493324c Mon Sep 17 00:00:00 2001 From: Mutasem Aldmour <4711238+mutdmour@users.noreply.github.com> Date: Tue, 30 Nov 2021 20:37:55 +0100 Subject: [PATCH] :bug: Fix draggable memory leak (#2503) * attempt fix * wrap in try catch * Revert "wrap in try catch" 4b0444747f7c2f724c18f7bab6b769fba1727f07 * :zap: Improve comment Co-authored-by: Jan Oberhauser --- packages/editor-ui/src/views/NodeView.vue | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/editor-ui/src/views/NodeView.vue b/packages/editor-ui/src/views/NodeView.vue index 239c3246c..de33d7e3b 100644 --- a/packages/editor-ui/src/views/NodeView.vue +++ b/packages/editor-ui/src/views/NodeView.vue @@ -2003,10 +2003,8 @@ export default mixins( this.$store.commit('renameNodeSelectedAndExecution', { old: currentName, new: newName }); // Reset all nodes and connections to load the new ones - if (this.instance) { - // On first load it does not exist - this.instance.deleteEveryEndpoint(); - } + this.deleteEveryEndpoint(); + this.$store.commit('removeAllConnections'); this.$store.commit('removeAllNodes', {setStateDirty: true}); @@ -2020,6 +2018,16 @@ export default mixins( this.deselectAllNodes(); this.nodeSelectedByName(newName); }, + deleteEveryEndpoint () { + // Check as it does not exist on first load + if (this.instance) { + const nodes = this.$store.getters.allNodes as INodeUi[]; + // @ts-ignore + nodes.forEach((node: INodeUi) => this.instance.destroyDraggable(`${NODE_NAME_PREFIX}${this.$store.getters.getNodeIndex(node.name)}`)); + + this.instance.deleteEveryEndpoint(); + } + }, matchCredentials(node: INodeUi) { if (!node.credentials) { return; @@ -2336,10 +2344,7 @@ export default mixins( }, resetWorkspace () { // Reset nodes - if (this.instance) { - // On first load it does not exist - this.instance.deleteEveryEndpoint(); - } + this.deleteEveryEndpoint(); if (this.executionWaitingForWebhook === true) { // Make sure that if there is a waiting test-webhook that