defer flow updates to next tick (#3211)

This commit is contained in:
Jonathan Dobson
2025-08-16 08:59:18 -04:00
committed by GitHub
parent 9a359ebfde
commit e2a8f52464

View File

@@ -619,12 +619,13 @@ function FlowRenderer({
) {
workflowChangesStore.setHasChanges(true);
}
// throttle onNodesChange to prevent cascading React updates
// defer update to next tick to prevent max recursion errors;
// NOTE: deferring too long causes node updates to be skipped
if (onNodesChangeTimeoutRef.current === null) {
onNodesChange(changes);
onNodesChangeTimeoutRef.current = setTimeout(() => {
onNodesChangeTimeoutRef.current = null;
}, 33); // ~30fps throttle
}, 0);
}
}}
onEdgesChange={onEdgesChange}