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:
parent
10d0e13483
commit
4db7ea16d2
2 changed files with 13 additions and 1 deletions
|
|
@ -60,7 +60,15 @@ export const mutateTemplate = async (
|
||||||
);
|
);
|
||||||
newNode.tool_mode = toolMode ?? node.tool_mode;
|
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?.();
|
callback?.();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const error = e as ResponseErrorDetailAPI;
|
const error = e as ResponseErrorDetailAPI;
|
||||||
|
|
|
||||||
|
|
@ -304,6 +304,10 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
isUserChange: boolean = true,
|
isUserChange: boolean = true,
|
||||||
callback?: () => void,
|
callback?: () => void,
|
||||||
) => {
|
) => {
|
||||||
|
if (!get().nodes.find((node) => node.id === id)) {
|
||||||
|
throw new Error("Node not found");
|
||||||
|
}
|
||||||
|
|
||||||
let newChange =
|
let newChange =
|
||||||
typeof change === "function"
|
typeof change === "function"
|
||||||
? change(get().nodes.find((node) => node.id === id)!)
|
? change(get().nodes.find((node) => node.id === id)!)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue