facebook/react · error · Error
Expected to see a frame at the next depth.
Error message
Expected to see a frame at the next depth.
What it means
When DevTools restores a persisted selection across commits, it walks newly mounted Fibers and compares each against the saved path (trackedPath set via setTrackedPath). Once the current Fiber's parent matches the best match so far, the code expects trackedPath[trackedPathMatchDepth + 1] to exist - the saved frames must extend one level deeper than what has matched. The throw means the saved path is shorter than the match depth implies: corrupted or stale selection-path state.
Source
Thrown at packages/react-devtools-shared/src/backend/fiber/renderer.js:7675
if (trackedPath === null || !mightBeOnTrackedPath) {
// Fast path: there's nothing to track so do nothing and ignore siblings.
return false;
}
const returnFiber = fiber.return;
const returnAlternate = returnFiber !== null ? returnFiber.alternate : null;
// By now we know there's some selection to restore, and this is a new Fiber.
// Is this newly mounted Fiber a direct child of the current best match?
// (This will also be true for new roots if we haven't matched anything yet.)
if (
trackedPathMatchFiber === returnFiber ||
(trackedPathMatchFiber === returnAlternate && returnAlternate !== null)
) {
// Is this the next Fiber we should select? Let's compare the frames.
const actualFrame = getPathFrame(fiber);
// $FlowFixMe[incompatible-use] found when upgrading Flow
const expectedFrame = trackedPath[trackedPathMatchDepth + 1];
if (expectedFrame === undefined) {
throw new Error('Expected to see a frame at the next depth.');
}
if (
actualFrame.index === expectedFrame.index &&
actualFrame.key === expectedFrame.key &&
actualFrame.displayName === expectedFrame.displayName
) {
// We have our next match.
trackedPathMatchFiber = fiber;
if (fiberInstance !== null && fiberInstance.kind === FIBER_INSTANCE) {
trackedPathMatchInstance = fiberInstance;
}
trackedPathMatchDepth++;
// Are we out of frames to match?
// $FlowFixMe[incompatible-use] found when upgrading Flow
if (trackedPathMatchDepth === trackedPath.length - 1) {
// There's nothing that can possibly match afterwards.
// Don't check the children.
mightBeOnTrackedPath = false;View on GitHub (pinned to eafeac097b)
Solutions
- Clear the persisted selection (deselect the element, or reload the page without the selection restored) - fresh selections rebuild a consistent trackedPath.
- Update the DevTools extension - selection-restore logic is patched regularly.
- Avoid deep-linking selections into trees whose shape changes between loads.
- If reproducible on current versions, file a React issue with the tree change that preceded the throw.
Defensive patterns
Strategy: fallback
Try / catch
// when embedding devtools-shared: recover by dropping the stale selection path
try {
this._bridge.send('operations', operations);
} catch (err) {
if (err.message.includes('Expected to see a frame at the next depth')) {
this._emitClearSelectedElement(); // trackedPath is corrupt; abandon selection restore
} else {
throw err;
}
} Prevention
- Clear persisted selections before hot-reload remounts (deselect, then edit code).
- Avoid deep-linking selections into trees whose shape changes between loads.
- Update DevTools regularly - selection-restore fixes ship with the extension.
When it happens
Trigger: Selection restore during handleCommitFiberRoot while the tree shape shifted under the saved path - fast refresh remounting components, dynamic list reordering, or filter changes altering depth - so matching descends past the end of the saved frames. Deep-link/persisted selections (reload with ?select= style restore) hit it most often.
Common situations: Editing code with an element selected while HMR remounts the subtree; keeping a selection across reloads in an app whose tree differs on second load; enabling/disabling component filters between sessions.
Related errors
- Expected the root instance to exist when computing a path
- Expected mounted root to have known pseudo key.
- Expected root pseudo key to be known.
- Expected counter to be known.
- The should not be any remaining suspense node children if th
AI-assisted analysis of facebook/react@eafeac097b (2026-08-21).
Data as JSON: /api/errors/0407bd70627dae52.
Report an issue: GitHub.