{"record":{"id":"a975dbbca7b8a3ff","repo":"vercel-labs/agent-browser","slug":"inspect-failed-result-result-type","errorCode":null,"errorMessage":"inspect failed: ${result && result.type}","messagePattern":"inspect failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/src/native/react/scripts.rs","lineNumber":147,"sourceCode":"  });\n\n  return JSON.stringify(nodes);\n})()\n\"#;\n\n/// Template for `inspect` — replace {{ID}} with the numeric fiber id.\npub const TREE_INSPECT: &str = r#\"\n(() => {\n  const id = {{ID}};\n  const hook = window.__REACT_DEVTOOLS_GLOBAL_HOOK__;\n{{PICK_RI}}\n  const __abRiId = __abPickReactRendererId(hook);\n  const ri = (__abRiId != null && hook.rendererInterfaces && hook.rendererInterfaces.get) ? hook.rendererInterfaces.get(__abRiId) : null;\n  if (!ri) throw new Error(\"No React renderer attached\");\n  if (!ri.hasElementWithId(id)) throw new Error(\"element \" + id + \" not found (page reloaded?)\");\n  const result = ri.inspectElement(__abRiId, id, null, true);\n  if (!result || result.type !== \"full-data\") {\n    throw new Error(\"inspect failed: \" + (result && result.type));\n  }\n  const v = result.value;\n  const name = ri.getDisplayNameForElementID(id);\n  const lines = [name + \" #\" + id];\n  if (v.key != null) lines.push(\"key: \" + JSON.stringify(v.key));\n  section(\"props\", v.props);\n  section(\"hooks\", v.hooks);\n  section(\"state\", v.state);\n  section(\"context\", v.context);\n  if (v.owners && v.owners.length) {\n    lines.push(\"rendered by: \" + v.owners.map((o) => o.displayName).join(\" > \"));\n  }\n  const source = Array.isArray(v.source)\n    ? [v.source[1], v.source[2], v.source[3]]\n    : null;\n  return JSON.stringify({ text: lines.join(\"\\n\"), source });\n\n  function section(label, payload) {","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/vercel-labs/agent-browser/blob/548b159b30eef119ccf6846c8bc807d0eaa3f6f8/cli/src/native/react/scripts.rs#L129-L165","documentation":"TREE_INSPECT calls ri.inspectElement(rendererId, id, null, true) and requires a result of type 'full-data'. React DevTools can return null or other result types (for example a 'hydrated' payload that needs a second inspect, or 'no-data') when the fiber re-rendered or unmounted between the snapshot and the inspect. The thrown message embeds the actual result type for diagnosis.","triggerScenarios":"Inspecting an element that unmounted or re-rendered (key change, route change, HMR) after the snapshot; inspecting immediately after a reload; concurrent features causing fiber churn during inspection.","commonSituations":"Agent flows that snapshot once and inspect much later; dev servers with hot reload invalidating fibers; animations/lists reordering element ids.","solutions":["Re-run 'react tree' and inspect the fresh id immediately","If the message says 'hydrated', simply call 'react inspect <id>' again — the second call returns full data","Pin down flaky pages first (wait for stable state) before inspecting"],"exampleFix":"# before\nagent-browser react inspect 42   # inspect failed: hydrated\n\n# after\nagent-browser react inspect 42   # call again; or re-snapshot:\nagent-browser react tree && agent-browser react inspect 17","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// try { await reactInspect(id); } catch (e) {\n//   if (/inspect failed: hydrated/.test(String(e))) retry once;\n//   else re-snapshot the tree and inspect the fresh id;\n// }","preventionTips":["Snapshot immediately before inspect on dynamic pages","Retry once on 'hydrated' — the second inspectElement call returns full-data","Avoid inspecting during HMR or route transitions"],"tags":["react","timing","devtools","stale-state"],"backgroundTag":null,"analyzedSha":"548b159b30eef119ccf6846c8bc807d0eaa3f6f8","analyzedAt":"2026-08-16T10:12:14.925Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}