{"record":{"id":"60ca6df017725bb5","repo":"facebook/react","slug":"could-not-find-devtoolsinstance-with-id-id","errorCode":null,"errorMessage":"Could not find DevToolsInstance with id \"${id}\"","messagePattern":"Could not find DevToolsInstance with id \"(.+?)\"","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/react-devtools-shared/src/backend/fiber/renderer.js","lineNumber":5232,"sourceCode":"      }\n      node.sibling.return = node.return;\n      node = node.sibling;\n    }\n  }\n\n  function findAllCurrentHostInstances(\n    devtoolsInstance: DevToolsInstance,\n  ): $ReadOnlyArray<HostInstance> {\n    const hostInstances: Array<HostInstance> = [];\n    appendHostInstancesByDevToolsInstance(devtoolsInstance, hostInstances);\n    return hostInstances;\n  }\n\n  function findHostInstancesForElementID(id: number) {\n    try {\n      const devtoolsInstance = idToDevToolsInstanceMap.get(id);\n      if (devtoolsInstance === undefined) {\n        console.warn(`Could not find DevToolsInstance with id \"${id}\"`);\n        return null;\n      }\n      return findAllCurrentHostInstances(devtoolsInstance);\n    } catch (err) {\n      // The fiber might have unmounted by now.\n      return null;\n    }\n  }\n\n  function findLastKnownRectsForID(id: number): null | Array<Rect> {\n    try {\n      const devtoolsInstance = idToDevToolsInstanceMap.get(id);\n      if (devtoolsInstance === undefined) {\n        console.warn(`Could not find DevToolsInstance with id \"${id}\"`);\n        return null;\n      }\n      if (devtoolsInstance.suspenseNode === null) {\n        return null;","sourceCodeStart":5214,"sourceCodeEnd":5250,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react-devtools-shared/src/backend/fiber/renderer.js#L5214-L5250","documentation":"findHostInstancesForElementID() (the Fiber backend's handler for the 'findHostInstancesForElementID' bridge command, used by 'Show the DOM nodes rendered by this component' and native-element highlighting) looked up the element id in idToDevToolsInstanceMap and got undefined. Entries are deleted the moment a fiber unmounts (recordUnmount, renderer.js:2071) or a virtual instance unmounts (recordVirtualUnmount, renderer.js:2804), so the id is from a tree snapshot the backend has already discarded. The function returns null after warning and callers degrade gracefully.","triggerScenarios":"Invoking 'Show the DOM nodes rendered by this component' after the component unmounted but before the panel refreshed its tree; the element got hidden by an enabled component filter; ids carried over from a previous page session via persisted state.","commonSituations":"Clicking inspect actions while the app navigates or Fast Refresh remounts; filtering components out mid-inspection; slow machines where the operations batch lags behind user interaction.","solutions":["Dismiss it as a race - wait for the Components tree to update, re-select the element, and retry.","Reload the page if the element is permanently gone so stale ids are flushed.","Check enabled component filters; a filtered element keeps its frontend id but disappears from the backend map.","Embedders: verify store.getElementByID(id) still returns the element before sending the bridge command."],"exampleFix":"// before (frontend)\nbridge.send('findHostInstancesForElementID', id);\n\n// after\nif (store.getElementByID(id) !== null) {\n  bridge.send('findHostInstancesForElementID', id);\n}","handlingStrategy":"validation","validationCode":"// frontend side: confirm the element is still in the tree before asking for host instances\nif (store.getElementByID(id) === null) {\n  return; // element unmounted or was filtered out\n}\nbridge.send('findHostInstancesForElementID', id);","typeGuard":"function isLiveElement(store: Store, id: number): boolean %checks {\n  return store.getElementByID(id) !== null;\n}","tryCatchPattern":null,"preventionTips":["Re-read store.getElementByID(id) at interaction time; never trust ids captured before the last operations batch.","Disable 'show DOM nodes' actions for elements the latest tree update removed.","Account for component filters: a filtered element keeps a frontend id but is gone from the backend map.","Expect unmount races in SPAs - the backend returning null is a normal, handled outcome."],"tags":["react-devtools","devtools-backend","stale-id","race-condition","unmounted-component"],"backgroundTag":"stale-element-reference","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}