[fix] Resolve workflow corruption from subgraph serialization #4929
+33
−15
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit fixes a critical issue where saving a workflow with complex subgraphs could lead to a corrupted file, causing errors upon loading.
The root cause was twofold:
Unsafe Object Cloning: The
LiteGraph.cloneObject
function usedJSON.stringify
, which cannot handle circular references that can exist in a nodes properties, especially in complex graphs with promoted widgets. This has been replaced with_.cloneDeep
from lodash for robust and safe deep cloning.Unsafe Node Configuration: The
LGraphNode.configure
method used a generic loop that would overwrite theinputs
andoutputs
arrays with plain objects from the serialized data. This created a temporary but dangerous state where class instances were replaced by plain objects, leading toTypeError
exceptions when methods or private fields were accessed on them. Theconfigure
method has been refactored to handleinputs
,outputs
, andproperties
explicitly and safely, ensuring they are always proper class instances.This fix makes the node loading process more robust and predictable, preventing data corruption and ensuring the stability of workflows with subgraphs.
Summary
Changes
Review Focus
Screenshots (if applicable)
┆Issue is synchronized with this Notion page by Unito