@samitouri / QOS-React / commits / a51f925217

[DevTools] Only check if we previously removed IO if its removal failed (#34506)

Sebastian "Sebbie" Silbermann committed Sep 16, 2025 at 19:55 UTC a51f925217e7c2a92fe4df707487acb29cb12b1e
1 file changed +22 -19
packages/react-devtools-shared/src/backend/fiber/renderer.js
+22 -19
@@ -2902,29 +2902,32 @@ 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 - }
2905 +
2906 if (
2907 suspendedBySet === undefined ||
2920 - (!alreadyRemovedIO && !suspendedBySet.delete(instance))
2908 + !suspendedBySet.delete(instance)
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 + }
2929 }
2927 - if (suspendedBySet.size === 0) {
2930 + if (suspendedBySet !== undefined && suspendedBySet.size === 0) {
2931 parentSuspenseNode.suspendedBy.delete(asyncInfo.awaited);
2932 }
2933 if (