{"record":{"id":"dc7c27041d7acbd6","repo":"tinyhumansai/openhuman","slug":"rpc-method-timed-out-after-timeoutms-ms","errorCode":null,"errorMessage":"RPC ${method} timed out after ${timeoutMs}ms","messagePattern":"RPC (.+?) timed out after (.+?)ms","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/debug/agent-prepare-context-audit.mjs","lineNumber":267,"sourceCode":"  let res;\n  try {\n    res = await fetch(coreUrl, {\n      method: \"POST\",\n      signal: controller.signal,\n      headers: {\n        \"content-type\": \"application/json\",\n        authorization: `Bearer ${token}`,\n      },\n      body: JSON.stringify({\n        jsonrpc: \"2.0\",\n        id: `apc-${Date.now()}-${Math.random().toString(16).slice(2)}`,\n        method,\n        params,\n      }),\n    });\n  } catch (err) {\n    if (err?.name === \"AbortError\")\n      throw new Error(`RPC ${method} timed out after ${timeoutMs}ms`);\n    throw err;\n  } finally {\n    clearTimeout(timeout);\n  }\n  const bodyText = await res.text();\n  let body;\n  try {\n    body = JSON.parse(bodyText);\n  } catch {\n    throw new Error(\n      `RPC ${method} returned non-JSON HTTP ${res.status}: ${bodyText.slice(0, 200)}`,\n    );\n  }\n  if (!res.ok) throw new Error(`RPC ${method} HTTP ${res.status}`);\n  if (body.error)\n    throw new Error(\n      `RPC ${method} error: ${JSON.stringify(body.error).slice(0, 300)}`,\n    );","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/a221052e0df5b1f7598fceba7329fd1af95d6699/scripts/debug/agent-prepare-context-audit.mjs#L249-L285","documentation":"The rpc() helper in scripts/debug/agent-prepare-context-audit.mjs wraps fetch with an AbortController set to the per-call timeout (default 600000 ms, overridable via --rpc-timeout-ms). When the abort fires, the fetch rejects with AbortError and is rethrown as 'RPC <method> timed out after <N>ms'. The audit drives real orchestrator/inference turns, which are the slow calls that typically hit this.","triggerScenarios":"Any single JSON-RPC call exceeding the timeout: a long openhuman.inference_agent_chat turn on a slow model, a first-turn with a cold memory index, a transcript_search over a huge workspace, or a core that is overloaded/paused. The default 10-minute budget is exceeded by heavy multi-case runs with big contexts.","commonSituations":"Running the full 5 default cases plus seeded transcript against a busy or resource-constrained core; slow provider endpoints during the LLM portion; debugging on a laptop where the core competes with a cargo build for CPU; timeout lowered too aggressively via --rpc-timeout-ms.","solutions":["Raise the budget: --rpc-timeout-ms 1200000 (20 min) or higher for slow models","Narrow the audit to one case (--query \"...\") to confirm it's volume, not a hang","Check the core is actually progressing (its logs/workspace) rather than deadlocked — a hang will time out at any budget","Use --model to pick a faster model if the turn itself is the slow part"],"exampleFix":"# before\n$ node scripts/debug/agent-prepare-context-audit.mjs\nError: RPC openhuman.inference_agent_chat timed out after 600000ms\n\n# after\n$ node scripts/debug/agent-prepare-context-audit.mjs --rpc-timeout-ms 1800000 --query \"what are my goals?\"","handlingStrategy":"retry","validationCode":"// Before a long audit, probe the slow path cheaply\nconst start = Date.now();\nawait rpc(coreUrl, token, \"core.ping\", {}, 10_000);\nif (Date.now() - start > 5_000) console.error(\"core is slow to answer — consider --rpc-timeout-ms 1800000\");","typeGuard":null,"tryCatchPattern":"for (let attempt = 1; attempt <= 2; attempt++) {\n  try {\n    return await rpc(coreUrl, token, method, params, opts.rpcTimeoutMs);\n  } catch (e) {\n    if (/timed out after/.test(e.message) && attempt === 1) {\n      opts.rpcTimeoutMs *= 2; // one retry with a doubled budget\n      continue;\n    }\n    throw e;\n  }\n}","preventionTips":["Default the budget to the slowest case you run: multi-case inference audits deserve --rpc-timeout-ms 1200000+","Narrow to --query when iterating on prompts; full 5-case runs are for final confirmation","Watch the core's own logs — a turn that times out at any budget is usually a stuck provider call"],"tags":["rpc","timeout","network","performance"],"backgroundTag":null,"analyzedSha":"a221052e0df5b1f7598fceba7329fd1af95d6699","analyzedAt":"2026-08-16T12:47:06.542Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}