{"record":{"id":"58c02fb53ab3c350","repo":"facebook/react","slug":"expected-the-root-instance-to-exist-when-computing","errorCode":null,"errorMessage":"Expected the root instance to exist when computing a path","messagePattern":"Expected the root instance to exist when computing a path","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react-devtools-shared/src/backend/fiber/renderer.js","lineNumber":7847,"sourceCode":"      if (preferredDisplayName !== null) {\n        break;\n      }\n      child = child.child;\n    }\n    return preferredDisplayName || fallbackDisplayName || 'Anonymous';\n  }\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,","sourceCodeStart":7829,"sourceCodeEnd":7865,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react-devtools-shared/src/backend/fiber/renderer.js#L7829-L7865","documentation":"getPathFrame() builds selection-path frames for Fibers; for a HostRoot fiber it looks up the root's DevTools instance in rootToFiberInstanceMap to derive a stable pseudo key. That map is only populated when the backend processes a root (initial flush, commits, filter re-mounts), so the throw means a path is being computed for a HostRoot the backend never registered - the same unregistered-root invariant as the inspect/profiling entry points.","triggerScenarios":"Computing an element path (selection capture/restore, copy-of-path features) for a root that exists in the Fiber sense but was never committed through the backend - unrendered createRoot() containers, roots created before attach, or roots appearing during a filter re-mount window.","commonSituations":"Persisting/restoring selection into a root that renders lazily; DevTools attached after page load; multi-root apps where one root has not rendered.","solutions":["Ensure the root has rendered at least once before selecting inside it.","Reload with DevTools open so every root is tracked from creation.","Keep React and DevTools versions matched and current.","File an issue if it reproduces on current versions with a committed root."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// in a custom integration: only capture paths for roots the backend tracks\nconst rootIsTracked = store.getRootsForRenderer(rendererID).some(r => r.id === rootID);\nif (rootIsTracked) {\n  bridge.send('getPathForElement', {id, rendererID});\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Render every root at least once before selecting/capturing paths inside it.","Attach DevTools before roots are created.","Keep React/DevTools versions matched; report repros involving committed roots."],"tags":["react-devtools","fiber-root","selection-restore","internal-invariant"],"backgroundTag":"unregistered-fiber-root","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}