Skip to content

Commit 0e516d3

Browse files
eps1lonclaude
andauthored
[devtools] Document that Store consistency throws must not be worked around (react#37035)
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent 71ecaf8 commit 0e516d3

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

  • packages/react-devtools-shared/src/devtools

packages/react-devtools-shared/src/devtools/store.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,7 @@ export default class Store extends EventEmitter<{
608608
root = this._idToElement.get(rootID);
609609

610610
if (root === undefined) {
611+
// We should never reach this. This is a bug in the backend renderer.
611612
this._throwAndEmitError(
612613
Error(
613614
`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<{
644645
const child = this._idToElement.get(childID);
645646

646647
if (child === undefined) {
648+
// We should never reach this. This is a bug in the backend renderer.
647649
this._throwAndEmitError(
648650
Error(
649651
`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<{
14311433
i += 3;
14321434

14331435
if (this._idToElement.has(id)) {
1436+
// We should never reach this. This is a bug in the backend renderer.
14341437
this._throwAndEmitError(
14351438
Error(
14361439
`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<{
15411544

15421545
const parentElement = this._idToElement.get(parentID);
15431546
if (parentElement === undefined) {
1547+
// We should never reach this. This is a bug in the backend renderer.
15441548
this._throwAndEmitError(
15451549
Error(
15461550
`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<{
16171621
const element = this._idToElement.get(id);
16181622

16191623
if (element === undefined) {
1624+
// We should never reach this. This is a bug in the backend renderer.
16201625
this._throwAndEmitError(
16211626
Error(
16221627
`Cannot remove node "${id}" because no matching node was found in the Store.`,
@@ -1630,6 +1635,7 @@ export default class Store extends EventEmitter<{
16301635

16311636
const {children, ownerID, parentID, weight} = element;
16321637
if (children.length > 0) {
1638+
// We should never reach this. This is a bug in the backend renderer.
16331639
this._throwAndEmitError(
16341640
Error(`Node "${id}" was removed before its children.`),
16351641
);
@@ -1657,6 +1663,7 @@ export default class Store extends EventEmitter<{
16571663

16581664
parentElement = this._idToElement.get(parentID);
16591665
if (parentElement === undefined) {
1666+
// We should never reach this. This is a bug in the backend renderer.
16601667
this._throwAndEmitError(
16611668
Error(
16621669
`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<{
16961703

16971704
const element = this._idToElement.get(id);
16981705
if (element === undefined) {
1706+
// We should never reach this. This is a bug in the backend renderer.
16991707
this._throwAndEmitError(
17001708
Error(
17011709
`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<{
17071715

17081716
const children = element.children;
17091717
if (children.length !== numChildren) {
1718+
// We should never reach this. This is a bug in the backend renderer.
17101719
this._throwAndEmitError(
17111720
Error(
17121721
`Children cannot be added or removed during a reorder operation.`,
@@ -1824,6 +1833,7 @@ export default class Store extends EventEmitter<{
18241833
let name = stringTable[nameStringID];
18251834

18261835
if (this._idToSuspense.has(id)) {
1836+
// We should never reach this. This is a bug in the backend renderer.
18271837
this._throwAndEmitError(
18281838
Error(
18291839
`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<{
18761886
if (parentID !== 0) {
18771887
const parentSuspense = this._idToSuspense.get(parentID);
18781888
if (parentSuspense === undefined) {
1889+
// We should never reach this. This is a bug in the backend renderer.
18791890
this._throwAndEmitError(
18801891
Error(
18811892
`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<{
19121923
const suspense = this._idToSuspense.get(id);
19131924

19141925
if (suspense === undefined) {
1926+
// We should never reach this. This is a bug in the backend renderer.
19151927
this._throwAndEmitError(
19161928
Error(
19171929
`Cannot remove suspense node "${id}" because no matching node was found in the Store.`,
@@ -1925,6 +1937,7 @@ export default class Store extends EventEmitter<{
19251937

19261938
const {children, parentID, rects} = suspense;
19271939
if (children.length > 0) {
1940+
// We should never reach this. This is a bug in the backend renderer.
19281941
this._throwAndEmitError(
19291942
Error(`Suspense node "${id}" was removed before its children.`),
19301943
);
@@ -1954,6 +1967,7 @@ export default class Store extends EventEmitter<{
19541967

19551968
parentSuspense = this._idToSuspense.get(parentID);
19561969
if (parentSuspense === undefined) {
1970+
// We should never reach this. This is a bug in the backend renderer.
19571971
this._throwAndEmitError(
19581972
Error(
19591973
`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<{
19651979

19661980
const index = parentSuspense.children.indexOf(id);
19671981
if (index === -1) {
1982+
// We should never reach this. This is a bug in the backend renderer.
19681983
this._throwAndEmitError(
19691984
Error(
19701985
`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<{
19852000

19862001
const suspense = this._idToSuspense.get(id);
19872002
if (suspense === undefined) {
2003+
// We should never reach this. This is a bug in the backend renderer.
19882004
this._throwAndEmitError(
19892005
Error(
19902006
`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<{
19962012

19972013
const children = suspense.children;
19982014
if (children.length !== numChildren) {
2015+
// We should never reach this. This is a bug in the backend renderer.
19992016
this._throwAndEmitError(
20002017
Error(
20012018
`Suspense children cannot be added or removed during a reorder operation.`,
@@ -2036,6 +2053,7 @@ export default class Store extends EventEmitter<{
20362053

20372054
const suspense = this._idToSuspense.get(id);
20382055
if (suspense === undefined) {
2056+
// We should never reach this. This is a bug in the backend renderer.
20392057
this._throwAndEmitError(
20402058
Error(
20412059
`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<{
21232141
const suspense = this._idToSuspense.get(id);
21242142

21252143
if (suspense === undefined) {
2144+
// We should never reach this. This is a bug in the backend renderer.
21262145
this._throwAndEmitError(
21272146
Error(
21282147
`Cannot update suspenders of suspense node "${id}" because no matching node was found in the Store.`,

0 commit comments

Comments
 (0)