File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
packages/react-devtools-shared/src/backend/fiber Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff 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. ' +
You can’t perform that action at this time.
0 commit comments