[DevTools] Fix memory leak when unmounting hoistables#35741
Merged
eps1lon merged 2 commits intofacebook:mainfrom Feb 10, 2026
Merged
[DevTools] Fix memory leak when unmounting hoistables#35741eps1lon merged 2 commits intofacebook:mainfrom
eps1lon merged 2 commits intofacebook:mainfrom
Conversation
731b9b6 to
2ae2122
Compare
hoxyq
approved these changes
Feb 10, 2026
|
Hey @hoxyq, how can we get Qodo agentic github review installed in the repo? |
github-actions bot
pushed a commit
to code/lib-react
that referenced
this pull request
Feb 15, 2026
DiffTrain build for [f23aa1d](facebook@f23aa1d)
github-actions bot
pushed a commit
to code/lib-react
that referenced
this pull request
Feb 15, 2026
DiffTrain build for [f23aa1d](facebook@f23aa1d)
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.
Summary
For Host Hoistables we have may have many devtools instances to choose from as the nearest instance since React Float may have deduplicated the public host instance. We keep an internal map from the public host instance to the chosen devtools instance. When we were unmounting a Host Hoistable, we pick the next Fiber that's also referencing the same public host instance.
Unfortunately we were using the wrong values when moving those pointers. This wasn't caught by Flow since our
HostInstancetype is any object so you can assign anything to it and assign it to anything (here we assigned aDevToolsInstanceto aHostInstance).We could improve type safety for those operations but it's quite involved. It's the only bug where we currently accidentally assign these two types. If this happens more often, we can harden the types.
Also ensures element inspection works when unmounting Hoist Hoistables. You'd have to actually inspect the DOM node to notice the bug. The memory leak you always get so I choose that bug as the headline.
Found with Claude + Opus 4.6
How did you test this change?