{"record":{"id":"dc9f7d381bfefaf8","repo":"facebook/react","slug":"expected-mounted-root-to-have-known-pseudo-key","errorCode":null,"errorMessage":"Expected mounted root to have known pseudo key.","messagePattern":"Expected mounted root to have known pseudo key\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react-devtools-shared/src/backend/fiber/renderer.js","lineNumber":7853,"sourceCode":"  }\n\n  function getPathFrame(fiber: Fiber): PathFrame {\n    const {key} = fiber;\n    let displayName = getDisplayNameForFiber(fiber);\n    const index = fiber.index;\n    switch (fiber.tag) {\n      case HostRoot:\n        // Roots don't have a real displayName, index, or key.\n        // Instead, we'll use the pseudo key (childDisplayName:indexWithThatName).\n        const rootInstance = rootToFiberInstanceMap.get(fiber.stateNode);\n        if (rootInstance === undefined) {\n          throw new Error(\n            'Expected the root instance to exist when computing a path',\n          );\n        }\n        const pseudoKey = rootPseudoKeys.get(rootInstance.id);\n        if (pseudoKey === undefined) {\n          throw new Error('Expected mounted root to have known pseudo key.');\n        }\n        displayName = pseudoKey;\n        break;\n      case HostComponent:\n        displayName = fiber.type;\n        break;\n      default:\n        break;\n    }\n    return {\n      displayName,\n      key: key === REACT_OPTIMISTIC_KEY ? null : key,\n      index,\n    };\n  }\n\n  function getVirtualPathFrame(virtualInstance: VirtualInstance): PathFrame {\n    return {","sourceCodeStart":7835,"sourceCodeEnd":7871,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react-devtools-shared/src/backend/fiber/renderer.js#L7835-L7871","documentation":"After resolving the root instance for a HostRoot fiber, getPathFrame() requires rootPseudoKeys to contain an entry for that instance's id. The pseudo key is written by setRootPseudoKey at initial flush, filter re-mount, and commit; the throw means a known root instance reached path computation without ever being keyed - registration and keying got out of sync.","triggerScenarios":"Path computation for a root that was registered in rootToFiberInstanceMap but skipped setRootPseudoKey - roots that appeared mid filter re-mount or during the attach window, or bookkeeping partially rewritten by a re-mount.","commonSituations":"Selection capture/restore right as a root mounts; toggling filters in multi-root apps; DevTools attach racing root creation.","solutions":["Reload the page with DevTools open to rebuild all root keys.","Re-select the element after the tree settles instead of relying on a selection persisted across the mount.","Update DevTools; keying coverage fixes land in react-devtools-shared.","Report a repro if current versions still throw."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// only persist/restore selection paths after the target root has committed and appears in the tree\nconst rootVisible = store.getElementByID(rootTreeID) != null;\nif (rootVisible) {\n  persistSelectionPath(id);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Re-select elements after roots mount rather than restoring selections captured mid-mount.","Reload with DevTools open so all roots are keyed during initial flush.","Update DevTools for root-keying coverage fixes."],"tags":["react-devtools","fiber-root","selection-restore","internal-invariant","bookkeeping"],"backgroundTag":"devtools-internal-invariant","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}