fix: make annotateDirtyNodesWithError return new nodes instead of mutating#14
Open
Av1ralS1ngh wants to merge 1 commit intorawBit-io:mainfrom
Open
fix: make annotateDirtyNodesWithError return new nodes instead of mutating#14Av1ralS1ngh wants to merge 1 commit intorawBit-io:mainfrom
Av1ralS1ngh wants to merge 1 commit intorawBit-io:mainfrom
Conversation
…ating node.data.error and node.data.extendedError were being set directly on node objects, bypassing the immutable update pattern used elsewhere in the codebase. Both call sites (payload-limit path and network-error path) now consume the returned mapped array.
2fe451f to
f3960f0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
annotateDirtyNodesWithError in graphUtils.ts was directly writing node.data.error = true and node.data.extendedError = message onto node objects. This bypasses the immutable update pattern used everywhere else in the codebase (via Immer) and violates React's expectation that state objects are not mutated in place. Both error paths: payload size exceeded and network/timeout failure were affected.
Fix
Convert the function from a void side-effect to a pure mapping function that returns a new array. Each dirty node gets a new object via { ...node, data: { ...node.data, ... } }. Non-dirty nodes are returned as-is (same reference). Both call sites updated to consume the returned array.