Skip to content

Commit 851bad0

Browse files
authored
[DevTools] Ignore repeated removals of the same IO (#34495)
1 parent 5e0c951 commit 851bad0

File tree

1 file changed

+14
-1
lines changed
  • packages/react-devtools-shared/src/backend/fiber

1 file changed

+14
-1
lines changed

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2902,9 +2902,22 @@ export function attach(
29022902
// Let's remove it from the parent SuspenseNode.
29032903
const ioInfo = asyncInfo.awaited;
29042904
const suspendedBySet = parentSuspenseNode.suspendedBy.get(ioInfo);
2905+
// A boundary can await the same IO multiple times.
2906+
// We still want to error if we're trying to remove IO that isn't present on
2907+
// this boundary so we need to check if we've already removed it.
2908+
// We're assuming previousSuspendedBy is a small array so this should be faster
2909+
// than allocating and maintaining a Set.
2910+
let alreadyRemovedIO = false;
2911+
for (let j = 0; j < i; j++) {
2912+
const removedIOInfo = previousSuspendedBy[j].awaited;
2913+
if (removedIOInfo === ioInfo) {
2914+
alreadyRemovedIO = true;
2915+
break;
2916+
}
2917+
}
29052918
if (
29062919
suspendedBySet === undefined ||
2907-
!suspendedBySet.delete(instance)
2920+
(!alreadyRemovedIO && !suspendedBySet.delete(instance))
29082921
) {
29092922
throw new Error(
29102923
'We are cleaning up async info that was not on the parent Suspense boundary. ' +

0 commit comments

Comments
 (0)