Stabilize reactFragments host node handle#434
Conversation
Greptile SummaryThis PR stabilizes the
Confidence Score: 2/5
Important Files Changed
Last reviewed commit: 1709ee7 |
e6c0162 to
5d353a4
Compare
5d353a4 to
1709ee7
Compare
| if (instance.unstable_reactFragments != null) { | ||
| instance.unstable_reactFragments.delete(fragmentInstance); | ||
| instance.reactFragments.delete(fragmentInstance); |
There was a problem hiding this comment.
Missed rename causes dead code / memory leak
The null-check on line 3605 still references the old property name unstable_reactFragments, but the property is now stored as reactFragments (set in addFragmentHandleToInstance). Since instance.unstable_reactFragments will always be undefined after this rename, the condition is never truthy, so reactFragments.delete(fragmentInstance) on line 3606 will never execute. This means fragment handles will accumulate on DOM nodes and never be cleaned up — a memory leak.
The Fabric renderer (ReactFiberConfigFabric.js:892) correctly renames both the check and the delete. This file should match:
| if (instance.unstable_reactFragments != null) { | |
| instance.unstable_reactFragments.delete(fragmentInstance); | |
| instance.reactFragments.delete(fragmentInstance); | |
| if (instance.reactFragments != null) { | |
| instance.reactFragments.delete(fragmentInstance); |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
Line: 3605-3606
Comment:
**Missed rename causes dead code / memory leak**
The null-check on line 3605 still references the old property name `unstable_reactFragments`, but the property is now stored as `reactFragments` (set in `addFragmentHandleToInstance`). Since `instance.unstable_reactFragments` will always be `undefined` after this rename, the condition is never truthy, so `reactFragments.delete(fragmentInstance)` on line 3606 will never execute. This means fragment handles will accumulate on DOM nodes and never be cleaned up — a memory leak.
The Fabric renderer (`ReactFiberConfigFabric.js:892`) correctly renames both the check and the delete. This file should match:
```suggestion
if (instance.reactFragments != null) {
instance.reactFragments.delete(fragmentInstance);
```
How can I resolve this? If you propose a fix, please make it concise.|
Upstream PR was closed or merged. Code is synced via branch mirror. |
Mirror of facebook/react#35642
Original author: jackpope
react/react#34935 Introduced
unstable_reactFragmentshandle on DOM nodes to enable caching of Observers.This has been tested in production and is stable so it can be rolled out with the Fragment Refs feature.