@@ -2902,29 +2902,32 @@ export function attach(
2902
2902
// Let's remove it from the parent SuspenseNode.
2903
2903
const ioInfo = asyncInfo.awaited;
2904
2904
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
- }
2905
+
2918
2906
if (
2919
2907
suspendedBySet === undefined ||
2920
- (!alreadyRemovedIO && ! suspendedBySet.delete(instance) )
2908
+ ! suspendedBySet.delete(instance)
2921
2909
) {
2922
- throw new Error(
2923
- 'We are cleaning up async info that was not on the parent Suspense boundary. ' +
2924
- 'This is a bug in React.',
2925
- );
2910
+ // A boundary can await the same IO multiple times.
2911
+ // We still want to error if we're trying to remove IO that isn't present on
2912
+ // this boundary so we need to check if we've already removed it.
2913
+ // We're assuming previousSuspendedBy is a small array so this should be faster
2914
+ // than allocating and maintaining a Set.
2915
+ let alreadyRemovedIO = false;
2916
+ for (let j = 0; j < i; j++) {
2917
+ const removedIOInfo = previousSuspendedBy[j].awaited;
2918
+ if (removedIOInfo === ioInfo) {
2919
+ alreadyRemovedIO = true;
2920
+ break;
2921
+ }
2922
+ }
2923
+ if (!alreadyRemovedIO) {
2924
+ throw new Error(
2925
+ 'We are cleaning up async info that was not on the parent Suspense boundary. ' +
2926
+ 'This is a bug in React.',
2927
+ );
2928
+ }
2926
2929
}
2927
- if (suspendedBySet.size === 0) {
2930
+ if (suspendedBySet !== undefined && suspendedBySet .size === 0) {
2928
2931
parentSuspenseNode.suspendedBy.delete(asyncInfo.awaited);
2929
2932
}
2930
2933
if (
0 commit comments