@samitouri / QOS-React / commits / 0e516d326c

[devtools] Document that Store consistency throws must not be worked around (#37035)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>

Sebastian "Sebbie" Silbermann committed Jul 16, 2026 at 15:04 UTC 0e516d326c9c3922c2584e42698b53ae4ab0d7e5
1 file changed +19
packages/react-devtools-shared/src/devtools/store.js
+19
@@ -608,6 +608,7 @@ export default class Store extends EventEmitter<{
608 root = this._idToElement.get(rootID);
609
610 if (root === undefined) {
611 + // We should never reach this. This is a bug in the backend renderer.
612 this._throwAndEmitError(
613 Error(
614 `Couldn't find root with id "${rootID}": no matching node was found in the Store.`,
@@ -644,6 +645,7 @@ export default class Store extends EventEmitter<{
645 const child = this._idToElement.get(childID);
646
647 if (child === undefined) {
648 + // We should never reach this. This is a bug in the backend renderer.
649 this._throwAndEmitError(
650 Error(
651 `Couldn't child element with id "${childID}": no matching node was found in the Store.`,
@@ -1431,6 +1433,7 @@ export default class Store extends EventEmitter<{
1433 i += 3;
1434
1435 if (this._idToElement.has(id)) {
1436 + // We should never reach this. This is a bug in the backend renderer.
1437 this._throwAndEmitError(
1438 Error(
1439 `Cannot add node "${id}" because a node with that id is already in the Store.`,
@@ -1541,6 +1544,7 @@ export default class Store extends EventEmitter<{
1544
1545 const parentElement = this._idToElement.get(parentID);
1546 if (parentElement === undefined) {
1547 + // We should never reach this. This is a bug in the backend renderer.
1548 this._throwAndEmitError(
1549 Error(
1550 `Cannot add child "${id}" to parent "${parentID}" because parent node was not found in the Store.`,
@@ -1617,6 +1621,7 @@ export default class Store extends EventEmitter<{
1621 const element = this._idToElement.get(id);
1622
1623 if (element === undefined) {
1624 + // We should never reach this. This is a bug in the backend renderer.
1625 this._throwAndEmitError(
1626 Error(
1627 `Cannot remove node "${id}" because no matching node was found in the Store.`,
@@ -1630,6 +1635,7 @@ export default class Store extends EventEmitter<{
1635
1636 const {children, ownerID, parentID, weight} = element;
1637 if (children.length > 0) {
1638 + // We should never reach this. This is a bug in the backend renderer.
1639 this._throwAndEmitError(
1640 Error(`Node "${id}" was removed before its children.`),
1641 );
@@ -1657,6 +1663,7 @@ export default class Store extends EventEmitter<{
1663
1664 parentElement = this._idToElement.get(parentID);
1665 if (parentElement === undefined) {
1666 + // We should never reach this. This is a bug in the backend renderer.
1667 this._throwAndEmitError(
1668 Error(
1669 `Cannot remove node "${id}" from parent "${parentID}" because no matching node was found in the Store.`,
@@ -1696,6 +1703,7 @@ export default class Store extends EventEmitter<{
1703
1704 const element = this._idToElement.get(id);
1705 if (element === undefined) {
1706 + // We should never reach this. This is a bug in the backend renderer.
1707 this._throwAndEmitError(
1708 Error(
1709 `Cannot reorder children for node "${id}" because no matching node was found in the Store.`,
@@ -1707,6 +1715,7 @@ export default class Store extends EventEmitter<{
1715
1716 const children = element.children;
1717 if (children.length !== numChildren) {
1718 + // We should never reach this. This is a bug in the backend renderer.
1719 this._throwAndEmitError(
1720 Error(
1721 `Children cannot be added or removed during a reorder operation.`,
@@ -1824,6 +1833,7 @@ export default class Store extends EventEmitter<{
1833 let name = stringTable[nameStringID];
1834
1835 if (this._idToSuspense.has(id)) {
1836 + // We should never reach this. This is a bug in the backend renderer.
1837 this._throwAndEmitError(
1838 Error(
1839 `Cannot add suspense node "${id}" because a suspense node with that id is already in the Store.`,
@@ -1876,6 +1886,7 @@ export default class Store extends EventEmitter<{
1886 if (parentID !== 0) {
1887 const parentSuspense = this._idToSuspense.get(parentID);
1888 if (parentSuspense === undefined) {
1889 + // We should never reach this. This is a bug in the backend renderer.
1890 this._throwAndEmitError(
1891 Error(
1892 `Cannot add suspense child "${id}" to parent suspense "${parentID}" because parent suspense node was not found in the Store.`,
@@ -1912,6 +1923,7 @@ export default class Store extends EventEmitter<{
1923 const suspense = this._idToSuspense.get(id);
1924
1925 if (suspense === undefined) {
1926 + // We should never reach this. This is a bug in the backend renderer.
1927 this._throwAndEmitError(
1928 Error(
1929 `Cannot remove suspense node "${id}" because no matching node was found in the Store.`,
@@ -1925,6 +1937,7 @@ export default class Store extends EventEmitter<{
1937
1938 const {children, parentID, rects} = suspense;
1939 if (children.length > 0) {
1940 + // We should never reach this. This is a bug in the backend renderer.
1941 this._throwAndEmitError(
1942 Error(`Suspense node "${id}" was removed before its children.`),
1943 );
@@ -1954,6 +1967,7 @@ export default class Store extends EventEmitter<{
1967
1968 parentSuspense = this._idToSuspense.get(parentID);
1969 if (parentSuspense === undefined) {
1970 + // We should never reach this. This is a bug in the backend renderer.
1971 this._throwAndEmitError(
1972 Error(
1973 `Cannot remove suspense node "${id}" from parent "${parentID}" because no matching node was found in the Store.`,
@@ -1965,6 +1979,7 @@ export default class Store extends EventEmitter<{
1979
1980 const index = parentSuspense.children.indexOf(id);
1981 if (index === -1) {
1982 + // We should never reach this. This is a bug in the backend renderer.
1983 this._throwAndEmitError(
1984 Error(
1985 `Cannot remove suspense node "${id}" from parent "${parentID}" because it is not a child of the parent.`,
@@ -1985,6 +2000,7 @@ export default class Store extends EventEmitter<{
2000
2001 const suspense = this._idToSuspense.get(id);
2002 if (suspense === undefined) {
2003 + // We should never reach this. This is a bug in the backend renderer.
2004 this._throwAndEmitError(
2005 Error(
2006 `Cannot reorder children for suspense node "${id}" because no matching node was found in the Store.`,
@@ -1996,6 +2012,7 @@ export default class Store extends EventEmitter<{
2012
2013 const children = suspense.children;
2014 if (children.length !== numChildren) {
2015 + // We should never reach this. This is a bug in the backend renderer.
2016 this._throwAndEmitError(
2017 Error(
2018 `Suspense children cannot be added or removed during a reorder operation.`,
@@ -2036,6 +2053,7 @@ export default class Store extends EventEmitter<{
2053
2054 const suspense = this._idToSuspense.get(id);
2055 if (suspense === undefined) {
2056 + // We should never reach this. This is a bug in the backend renderer.
2057 this._throwAndEmitError(
2058 Error(
2059 `Cannot set rects for suspense node "${id}" because no matching node was found in the Store.`,
@@ -2123,6 +2141,7 @@ export default class Store extends EventEmitter<{
2141 const suspense = this._idToSuspense.get(id);
2142
2143 if (suspense === undefined) {
2144 + // We should never reach this. This is a bug in the backend renderer.
2145 this._throwAndEmitError(
2146 Error(
2147 `Cannot update suspenders of suspense node "${id}" because no matching node was found in the Store.`,