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

This commit is contained in:
Brian Vaughn
2021-09-17 12:53:07 -04:00
committed by GitHub
parent bc9bb87c2b
commit f50ff357cf
@@ -1140,6 +1140,13 @@ export function attach(
untrackFibersSet.add(fiber);
// React may detach alternate pointers during unmount;
// Since our untracking code is async, we should explicily track the pending alternate here as well.
const alternate = fiber.alternate;
if (alternate !== null) {
untrackFibersSet.add(alternate);
}
if (untrackFibersTimeoutID === null) {
untrackFibersTimeoutID = setTimeout(untrackFibers, 1000);
}