Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 22 additions & 19 deletions packages/react-devtools-shared/src/backend/fiber/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2902,29 +2902,32 @@ export function attach(
// Let's remove it from the parent SuspenseNode.
const ioInfo = asyncInfo.awaited;
const suspendedBySet = parentSuspenseNode.suspendedBy.get(ioInfo);
// A boundary can await the same IO multiple times.
// We still want to error if we're trying to remove IO that isn't present on
// this boundary so we need to check if we've already removed it.
// We're assuming previousSuspendedBy is a small array so this should be faster
// than allocating and maintaining a Set.
let alreadyRemovedIO = false;
for (let j = 0; j < i; j++) {
const removedIOInfo = previousSuspendedBy[j].awaited;
if (removedIOInfo === ioInfo) {
alreadyRemovedIO = true;
break;
}
}

if (
suspendedBySet === undefined ||
(!alreadyRemovedIO && !suspendedBySet.delete(instance))
!suspendedBySet.delete(instance)
) {
throw new Error(
'We are cleaning up async info that was not on the parent Suspense boundary. ' +
'This is a bug in React.',
);
// A boundary can await the same IO multiple times.
// We still want to error if we're trying to remove IO that isn't present on
// this boundary so we need to check if we've already removed it.
// We're assuming previousSuspendedBy is a small array so this should be faster
// than allocating and maintaining a Set.
let alreadyRemovedIO = false;
for (let j = 0; j < i; j++) {
const removedIOInfo = previousSuspendedBy[j].awaited;
if (removedIOInfo === ioInfo) {
alreadyRemovedIO = true;
break;
}
}
if (!alreadyRemovedIO) {
throw new Error(
'We are cleaning up async info that was not on the parent Suspense boundary. ' +
'This is a bug in React.',
);
}
}
if (suspendedBySet.size === 0) {
if (suspendedBySet !== undefined && suspendedBySet.size === 0) {
parentSuspenseNode.suspendedBy.delete(asyncInfo.awaited);
}
if (
Expand Down
Loading