Skip to content

Commit

Permalink
DevTools: Fix memory leak via alternate Fiber pointer (#22346)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Vaughn committed Sep 17, 2021
1 parent bc9bb87 commit f50ff35
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/react-devtools-shared/src/backend/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit f50ff35

Please sign in to comment.