facebook/react · error · Error
Expected the root instance to exist when computing a path
Error message
Expected the root instance to exist when computing a path
What it means
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.
Source
Thrown at packages/react-devtools-shared/src/backend/fiber/renderer.js:7847
if (preferredDisplayName !== null) {
break;
}
child = child.child;
}
return preferredDisplayName || fallbackDisplayName || 'Anonymous';
}
function getPathFrame(fiber: Fiber): PathFrame {
const {key} = fiber;
let displayName = getDisplayNameForFiber(fiber);
const index = fiber.index;
switch (fiber.tag) {
case HostRoot:
// Roots don't have a real displayName, index, or key.
// Instead, we'll use the pseudo key (childDisplayName:indexWithThatName).
const rootInstance = rootToFiberInstanceMap.get(fiber.stateNode);
if (rootInstance === undefined) {
throw new Error(
'Expected the root instance to exist when computing a path',
);
}
const pseudoKey = rootPseudoKeys.get(rootInstance.id);
if (pseudoKey === undefined) {
throw new Error('Expected mounted root to have known pseudo key.');
}
displayName = pseudoKey;
break;
case HostComponent:
displayName = fiber.type;
break;
default:
break;
}
return {
displayName,
key: key === REACT_OPTIMISTIC_KEY ? null : key,View on GitHub (pinned to eafeac097b)
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.
Defensive patterns
Strategy: validation
Validate before calling
// in a custom integration: only capture paths for roots the backend tracks
const rootIsTracked = store.getRootsForRenderer(rendererID).some(r => r.id === rootID);
if (rootIsTracked) {
bridge.send('getPathForElement', {id, rendererID});
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Persisting/restoring selection into a root that renders lazily; DevTools attached after page load; multi-root apps where one root has not rendered.
Related errors
- Expected mounted root to have known pseudo key.
- Expected to see a frame at the next depth.
- Expected root pseudo key to be known.
- Expected counter to be known.
- Expected a root instance to exist for this Fiber root
AI-assisted analysis of facebook/react@eafeac097b (2026-08-21).
Data as JSON: /api/errors/58c02fb53ab3c350.
Report an issue: GitHub.