Skip to content

Commit 2a66800

Browse files
committed
[DevTools] Ignore repeated removals of the same IO
1 parent 47664de commit 2a66800

File tree

1 file changed

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

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2890,6 +2890,11 @@ export function attach(
28902890
// is no longer in the new set.
28912891
if (previousSuspendedBy !== null && parentSuspenseNode !== null) {
28922892
const nextSuspendedBy = instance.suspendedBy;
2893+
// A boundary can await the same IO multiple times.
2894+
// We still want to error if we're trying to remove IO that isn't present on
2895+
// this boundary. We're tracking the IO we already removed so that we can error
2896+
// every time a delete fails.
2897+
const removedIOInfos = new Set<ReactIOInfo>();
28932898
for (let i = 0; i < previousSuspendedBy.length; i++) {
28942899
const asyncInfo = previousSuspendedBy[i];
28952900
if (
@@ -2904,13 +2909,14 @@ export function attach(
29042909
const suspendedBySet = parentSuspenseNode.suspendedBy.get(ioInfo);
29052910
if (
29062911
suspendedBySet === undefined ||
2907-
!suspendedBySet.delete(instance)
2912+
(!removedIOInfos.has(ioInfo) && !suspendedBySet.delete(instance))
29082913
) {
29092914
throw new Error(
29102915
'We are cleaning up async info that was not on the parent Suspense boundary. ' +
29112916
'This is a bug in React.',
29122917
);
29132918
}
2919+
removedIOInfos.add(ioInfo);
29142920
if (suspendedBySet.size === 0) {
29152921
parentSuspenseNode.suspendedBy.delete(asyncInfo.awaited);
29162922
}

0 commit comments

Comments
 (0)