@samitouri / QOS-React-2 / commits / f50ff357cf

DevTools: Fix memory leak via alternate Fiber pointer (#22346)

Brian Vaughn committed Sep 17, 2021 at 12:53 UTC f50ff357cf45d5cbda8d5a99c247e33b0477e936
1 file changed +7
packages/react-devtools-shared/src/backend/renderer.js
+7
@@ -1140,6 +1140,13 @@ export function attach(
1140
1141 untrackFibersSet.add(fiber);
1142
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 +
1150 if (untrackFibersTimeoutID === null) {
1151 untrackFibersTimeoutID = setTimeout(untrackFibers, 1000);
1152 }