Skip to content

Commit f50ff35

Browse files
author
Brian Vaughn
authored
DevTools: Fix memory leak via alternate Fiber pointer (#22346)
1 parent bc9bb87 commit f50ff35

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

packages/react-devtools-shared/src/backend/renderer.js

+7
Original file line numberDiff line numberDiff line change
@@ -1140,6 +1140,13 @@ export function attach(
11401140

11411141
untrackFibersSet.add(fiber);
11421142

1143+
// React may detach alternate pointers during unmount;
1144+
// Since our untracking code is async, we should explicily track the pending alternate here as well.
1145+
const alternate = fiber.alternate;
1146+
if (alternate !== null) {
1147+
untrackFibersSet.add(alternate);
1148+
}
1149+
11431150
if (untrackFibersTimeoutID === null) {
11441151
untrackFibersTimeoutID = setTimeout(untrackFibers, 1000);
11451152
}

0 commit comments

Comments
 (0)