From ad8fd8fecc24be57f5333c286e1751124b212e6f Mon Sep 17 00:00:00 2001 From: hjlarry Date: Thu, 7 Aug 2025 17:45:38 +0800 Subject: [PATCH] clone the node to avoid loro recursive --- .../core/collaboration-manager.ts | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/web/app/components/workflow/collaboration/core/collaboration-manager.ts b/web/app/components/workflow/collaboration/core/collaboration-manager.ts index 8e565bd700..e491ebc2fd 100644 --- a/web/app/components/workflow/collaboration/core/collaboration-manager.ts +++ b/web/app/components/workflow/collaboration/core/collaboration-manager.ts @@ -129,13 +129,17 @@ export class CollaborationManager { newNodes.forEach((newNode) => { const oldNode = oldNodesMap.get(newNode.id) if (!oldNode) { - this.nodesMap.set(newNode.id, newNode) + const persistentData = this.getPersistentNodeData(newNode) + const clonedData = JSON.parse(JSON.stringify(persistentData)) + this.nodesMap.set(newNode.id, clonedData) } else { const oldPersistentData = this.getPersistentNodeData(oldNode) const newPersistentData = this.getPersistentNodeData(newNode) - if (!isEqual(oldPersistentData, newPersistentData)) - this.nodesMap.set(newNode.id, newPersistentData) + if (!isEqual(oldPersistentData, newPersistentData)) { + const clonedData = JSON.parse(JSON.stringify(newPersistentData)) + this.nodesMap.set(newNode.id, clonedData) + } } }) } @@ -153,10 +157,14 @@ export class CollaborationManager { newEdges.forEach((newEdge) => { const oldEdge = oldEdgesMap.get(newEdge.id) - if (!oldEdge) - this.edgesMap.set(newEdge.id, newEdge) - else if (!isEqual(oldEdge, newEdge)) - this.edgesMap.set(newEdge.id, newEdge) + if (!oldEdge) { + const clonedEdge = JSON.parse(JSON.stringify(newEdge)) + this.edgesMap.set(newEdge.id, clonedEdge) + } + else if (!isEqual(oldEdge, newEdge)) { + const clonedEdge = JSON.parse(JSON.stringify(newEdge)) + this.edgesMap.set(newEdge.id, clonedEdge) + } }) }