@samitouri / QOS-React / commits / b58a8e3c40

[DevTools] Handle mount of disconnected Suspense boundaries (#34208)

Sebastian "Sebbie" Silbermann committed Aug 18, 2025 at 10:15 UTC b58a8e3c405ff5bb0ae4f8bb883c9f4e633d2b41
1 file changed +21 -11
packages/react-devtools-shared/src/devtools/store.js
+21 -11
@@ -1206,6 +1206,14 @@ export default class Store extends EventEmitter<{
1206 }
1207 set.add(id);
1208 }
1209 +
1210 + const suspense = this._idToSuspense.get(id);
1211 + if (suspense !== undefined) {
1212 + // We're reconnecting a node.
1213 + if (suspense.name === null) {
1214 + suspense.name = this._guessSuspenseName(element);
1215 + }
1216 + }
1217 }
1218 break;
1219 }
@@ -1432,21 +1440,12 @@ export default class Store extends EventEmitter<{
1440
1441 const element = this._idToElement.get(id);
1442 if (element === undefined) {
1435 - this._throwAndEmitError(
1436 - Error(
1437 - `Cannot add suspense node "${id}" because no matching element was found in the Store.`,
1438 - ),
1439 - );
1443 + // This element isn't connected yet.
1444 } else {
1445 if (name === null) {
1446 // The boundary isn't explicitly named.
1447 // Pick a sensible default.
1444 - // TODO: Use key
1445 - const owner = this._idToElement.get(element.ownerID);
1446 - if (owner !== undefined) {
1447 - // TODO: This is clowny
1448 - name = `${owner.displayName || 'Unknown'}>?`;
1449 - }
1448 + name = this._guessSuspenseName(element);
1449 }
1450 }
1451
@@ -1936,4 +1935,15 @@ export default class Store extends EventEmitter<{
1935 // and for unit testing the Store itself.
1936 throw error;
1937 }
1938 +
1939 + _guessSuspenseName(element: Element): string | null {
1940 + // TODO: Use key
1941 + const owner = this._idToElement.get(element.ownerID);
1942 + if (owner !== undefined) {
1943 + // TODO: This is clowny
1944 + return `${owner.displayName || 'Unknown'}>?`;
1945 + }
1946 +
1947 + return null;
1948 + }
1949 }