bug-fix: DevTools - Error logic for missing nodes while deletion#482
bug-fix: DevTools - Error logic for missing nodes while deletion#482everettbu wants to merge 2 commits into
Conversation
Greptile OverviewGreptile SummaryThis PR changes React DevTools Store handling of The change is localized to Confidence Score: 3/5
Important Files Changed
|
| - So I changed it to look for further nodes and skip removing this node | ||
| - logically as it is absent so its better logically | ||
| */ | ||
| i += 1; |
There was a problem hiding this comment.
Silent store corruption risk
When element is missing, this now advances i and continues without emitting any error. This makes the store silently diverge from the backend’s operation stream (and can hide real protocol bugs), which is hard to diagnose. If the intent is to treat this as a recoverable out-of-order remove, it should still report a non-fatal warning (e.g. this._throwAndEmitError(...) without aborting the batch) so DevTools doesn’t crash but developers still get visibility into the inconsistency.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/react-devtools-shared/src/devtools/store.js
Line: 1579:1582
Comment:
**Silent store corruption risk**
When `element` is missing, this now advances `i` and `continue`s without emitting any error. This makes the store silently diverge from the backend’s operation stream (and can hide real protocol bugs), which is hard to diagnose. If the intent is to treat this as a recoverable out-of-order remove, it should still report a non-fatal warning (e.g. `this._throwAndEmitError(...)` without aborting the batch) so DevTools doesn’t crash but developers still get visibility into the inconsistency.
How can I resolve this? If you propose a fix, please make it concise.| - Our store may be partially updated because of this logic | ||
| - So I changed it to look for further nodes and skip removing this node | ||
| - logically as it is absent so its better logically | ||
| */ | ||
| i += 1; |
There was a problem hiding this comment.
Avoid large inline comment
This block comment is very long and includes non-actionable bullets; it will age poorly in a hot path. Consider replacing it with a short sentence explaining why a missing node removal is skipped (and keep detailed rationale in the PR description or an issue link).
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/react-devtools-shared/src/devtools/store.js
Line: 1578:1582
Comment:
**Avoid large inline comment**
This block comment is very long and includes non-actionable bullets; it will age poorly in a hot path. Consider replacing it with a short sentence explaining *why* a missing node removal is skipped (and keep detailed rationale in the PR description or an issue link).
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.Refactor logic to skip removing absent nodes without error.
Additional Comments (1)
Prompt To Fix With AIThis is a comment left during a code review.
Path: packages/react-devtools-shared/src/devtools/store.js
Line: 1624:1626
Comment:
**Incorrect splice on -1**
If the parent exists but doesn't list `id` in `parentElement.children`, `indexOf(id)` returns `-1` and `splice(-1, 1)` will remove the *last* child, corrupting the store. This can happen if we receive duplicate/out-of-order remove ops or if a previous invalid remove was skipped. Guard `index !== -1` before splicing, and treat the missing-child case as a recoverable inconsistency (e.g. emit a non-fatal warning / skip adjusting children for this id).
How can I resolve this? If you propose a fix, please make it concise. |
|
This pull request has been automatically marked as stale. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize reviewing it yet. Your contribution is very much appreciated. |
|
Closing this pull request after a prolonged period of inactivity. If this issue is still present in the latest release, please ask for this pull request to be reopened. Thank you! |
Mirror of facebook/react#35716
Original author: 11Warrior
Summary
How did you test this change?
Fixes #35713