fix: add error handling when node stops existing before update completes (#8291)

Added error handling when node is not existent
This commit is contained in:
Lucas Oliveira 2025-05-30 13:09:41 -03:00 committed by GitHub
commit 4db7ea16d2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 1 deletions

View file

@ -60,7 +60,15 @@ export const mutateTemplate = async (
);
newNode.tool_mode = toolMode ?? node.tool_mode;
}
setNodeClass(newNode);
try {
setNodeClass(newNode);
} catch (e) {
if (e instanceof Error && e.message === "Node not found") {
console.log("Node not found");
} else {
throw e;
}
}
callback?.();
} catch (e) {
const error = e as ResponseErrorDetailAPI;

View file

@ -304,6 +304,10 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
isUserChange: boolean = true,
callback?: () => void,
) => {
if (!get().nodes.find((node) => node.id === id)) {
throw new Error("Node not found");
}
let newChange =
typeof change === "function"
? change(get().nodes.find((node) => node.id === id)!)