[DevTools] Ignore repeated removals of the same IO (#34495)
Sebastian "Sebbie" Silbermann committed
Sep 16, 2025 at 18:54 UTC
851bad0c88cd0c2933035034109a060689d49f27
1 file changed
+14
-1
packages/react-devtools-shared/src/backend/fiber/renderer.js
+14
-1
@@ -2902,9 +2902,22 @@ export function attach(
2902
// Let's remove it from the parent SuspenseNode.
2903
const ioInfo = asyncInfo.awaited;
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
+ }
2918
if (
2919
suspendedBySet === undefined ||
2907
- !suspendedBySet.delete(instance)
2920
+ (!alreadyRemovedIO && !suspendedBySet.delete(instance))
2921
) {
2922
throw new Error(
2923
'We are cleaning up async info that was not on the parent Suspense boundary. ' +