Skip to content

fix[devtools]: gracefully handle missing nodes in TREE_OPERATION_REMOVE instead of crashing#36475

Open
MD-Mushfiqur123 wants to merge 1 commit into
facebook:mainfrom
MD-Mushfiqur123:fix/devtools-remove-node-crash
Open

fix[devtools]: gracefully handle missing nodes in TREE_OPERATION_REMOVE instead of crashing#36475
MD-Mushfiqur123 wants to merge 1 commit into
facebook:mainfrom
MD-Mushfiqur123:fix/devtools-remove-node-crash

Conversation

@MD-Mushfiqur123
Copy link
Copy Markdown

Summary

When React re-renders components quickly (e.g., during scrolling or rapid state updates), DevTools tree operations can arrive out of order. This causes TREE_OPERATION_REMOVE to either:

  • Try removing a node that was already removed in a previous operation
  • Try removing a node from a parent that was already removed

The previous code called this._throwAndEmitError() which crashes the entire DevTools extension and shows an error overlay. This fix gracefully handles these race conditions by logging a warning (debug builds only) and skipping to the next operation.

Changes

In packages/react-devtools-shared/src/devtools/store.js:

Before After
_throwAndEmitError(Error(...)) + break if (__DEBUG__) { console.warn(...) } + continue
🚫 Crashes DevTools on race condition Gracefully skips already-removed nodes

Key design decisions:

  • continue instead of break: If one node in a batch is already gone, we should still process the rest of the batch
  • __DEBUG__ guard: Warnings only in debug builds; production silently handles the race condition
  • Legitimate errors preserved: The "Node was removed before its children" error still correctly throws (that's a real logic bug, not a race condition)

Related Issues

Fixes #33738, #25884

Test Plan

  • Manual code review — changes are minimal and targeted
  • Existing Store tests should pass (note: requires full React build setup)

…VE instead of crashing

When React re-renders components quickly (e.g., scrolling), tree operations
can arrive out of order, causing TREE_OPERATION_REMOVE to try removing
a node or referencing a parent that was already removed.

The previous code called _throwAndEmitError which crashes the entire
DevTools extension. This fix replaces the crash with a graceful skip:
- Log a warning only in debug builds
- Use 'continue' instead of 'break' to process remaining operations

Fixes facebook#33738, facebook#25884
@meta-cla
Copy link
Copy Markdown

meta-cla Bot commented May 14, 2026

Hi @MD-Mushfiqur123!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla
Copy link
Copy Markdown

meta-cla Bot commented May 14, 2026

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla Bot added the CLA Signed label May 14, 2026
@meta-cla
Copy link
Copy Markdown

meta-cla Bot commented May 14, 2026

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[DevTools Bug] Cannot remove node "810" because no matching node was found in the Store.

1 participant