{"record":{"id":"75a932587cd7c571","repo":"facebook/react","slug":"invalid-internal-instance-internalinstance","errorCode":null,"errorMessage":"Invalid internal instance: ${internalInstance}","messagePattern":"Invalid internal instance: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react-devtools-shared/src/backend/legacy/renderer.js","lineNumber":194,"sourceCode":"      // Not implemented.\n      return null;\n    };\n    findHostInstanceForInternalID = (id: number) => {\n      // Not implemented.\n      return null;\n    };\n  }\n\n  const supportsTogglingSuspense = false;\n\n  function getDisplayNameForElementID(id: number): string | null {\n    const internalInstance = idToInternalInstanceMap.get(id);\n    return internalInstance ? getData(internalInstance).displayName : null;\n  }\n\n  function getID(internalInstance: InternalInstance): number {\n    if (typeof internalInstance !== 'object' || internalInstance === null) {\n      throw new Error('Invalid internal instance: ' + internalInstance);\n    }\n    if (!internalInstanceToIDMap.has(internalInstance)) {\n      const id = getUID();\n      internalInstanceToIDMap.set(internalInstance, id);\n      idToInternalInstanceMap.set(id, internalInstance);\n    }\n    return internalInstanceToIDMap.get(internalInstance) as any as number;\n  }\n\n  function areEqualArrays(a: Array<any>, b: Array<any>) {\n    if (a.length !== b.length) {\n      return false;\n    }\n    for (let i = 0; i < a.length; i++) {\n      if (a[i] !== b[i]) {\n        return false;\n      }\n    }","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react-devtools-shared/src/backend/legacy/renderer.js#L176-L212","documentation":"In the legacy (React 15 stack reconciler) backend, getID() assigns stable numeric ids to internal instances and validates that the instance is a non-null object before using the id WeakMaps. The throw means traversal handed a primitive (string, number, null/undefined, boolean) where a composite or host internal instance was expected - DevTools could not even key the node.","triggerScenarios":"React 15 trees where _renderedChildren/_renderedComponent contain raw text/number nodes or nulls in a shape the backend did not filter out first, or another extension/monkey-patch altering the legacy Reconciler's arguments so args[0] is no longer the internal instance.","commonSituations":"Legacy React 15 apps inspected with modern DevTools; two React DevTools versions (extension + embedded) or other React tools (old perf tools) patching the same Reconciler methods; custom renderers imitating the React 15 legacy API incorrectly.","solutions":["Disable other React-related extensions and any duplicate/embedded DevTools so only one backend patches React 15.","Reload the page after disabling duplicates so the reconciler methods are patched exactly once.","If you embed devtools-shared against React 15, filter children with getElementType(child) === ElementTypeOtherOrUnknown before touching ids (as the stock traversal does).","Longer term, upgrade the app off React 15 - the legacy backend exists only for it."],"exampleFix":"// before (custom traversal over legacy children)\nconst id = getID(child); // throws for raw text/null children\n\n// after\nif (typeof child === 'object' && child !== null && getElementType(child) !== ElementTypeOtherOrUnknown) {\n  const id = getID(child);\n}","handlingStrategy":"type-guard","validationCode":"// filter legacy children before touching ids, matching the stock traversal\nconst children = getChildren(instance).filter(\n  child => typeof child === 'object' && child !== null,\n);","typeGuard":"function isInternalInstance(value) {\n  return typeof value === 'object' && value !== null;\n}","tryCatchPattern":null,"preventionTips":["Run only one React DevTools instance against a React 15 page - duplicate monkey-patching corrupts Reconciler arguments.","Reload after disabling duplicate extensions so patches apply exactly once.","Prefer migrating off React 15; the legacy backend is best-effort."],"tags":["react-devtools","legacy-react","react-15","internal-instance","monkey-patching"],"backgroundTag":"invalid-internal-instance","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}