{"record":{"id":"cfcef46f49491349","repo":"tinyhumansai/openhuman","slug":"timed-out-waiting-for-spawned-core-at-coreurl-n","errorCode":null,"errorMessage":"timed out waiting for spawned core at ${coreUrl}\\n${stderrFn()}","messagePattern":"timed out waiting for spawned core at (.+?)\\\\n(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/debug/agent-prepare-context-audit.mjs","lineNumber":627,"sourceCode":"  await waitForCore(opts.coreUrl, token, child, () => stderr);\n  return { child, token };\n}\n\nasync function waitForCore(coreUrl, token, child, stderrFn) {\n  const deadline = Date.now() + 180_000;\n  while (Date.now() < deadline) {\n    if (child.exitCode !== null)\n      throw new Error(\n        `spawned core exited with ${child.exitCode}\\n${stderrFn()}`,\n      );\n    try {\n      await rpc(coreUrl, token, \"core.ping\", {}, 10_000);\n      return;\n    } catch {\n      await new Promise((r) => setTimeout(r, 750));\n    }\n  }\n  throw new Error(\n    `timed out waiting for spawned core at ${coreUrl}\\n${stderrFn()}`,\n  );\n}\n\nasync function stopChild(child) {\n  if (child.exitCode !== null || child.signalCode !== null) return;\n  child.kill(\"SIGTERM\");\n  const exited = await Promise.race([\n    once(child, \"exit\").then(() => true),\n    new Promise((r) => setTimeout(() => r(false), 5_000)),\n  ]);\n  if (exited || child.exitCode !== null || child.signalCode !== null) return;\n  child.kill(\"SIGKILL\");\n  await Promise.race([\n    once(child, \"exit\"),\n    new Promise((r) => setTimeout(r, 2_000)),\n  ]);\n}","sourceCodeStart":609,"sourceCodeEnd":645,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/a221052e0df5b1f7598fceba7329fd1af95d6699/scripts/debug/agent-prepare-context-audit.mjs#L609-L645","documentation":"waitForCore() in scripts/debug/agent-prepare-context-audit.mjs gives the spawned core 180 seconds (750ms ping interval, 10s per core.ping attempt) to answer; if the deadline passes with the child still alive but core.ping never succeeding, it throws 'timed out waiting for spawned core at <url>' plus the stderr tail. Unlike error 217, the core did NOT exit — it just never became RPC-ready in time.","triggerScenarios":"--spawn-core with a cold cargo target directory: `cargo run` compiles the openhuman-core binary first, and a cold build of this large crate routinely exceeds 180s, so the wait times out while rustc is still running. Also: the core binding a different port than the URL polled, first-boot workspace migrations/model setup being slow, or the core starting but the ping being rejected (auth mismatch between the injected OPENHUMAN_CORE_TOKEN and what the core expects).","commonSituations":"First --spawn-core run after a clean clone or cargo clean; running right after a branch switch that invalidates the build cache; a slower CI box or laptop where compile plus boot overshoots 3 minutes; the child stuck on a network fetch during boot (never exits, never serves).","solutions":["Pre-build, then re-run: cargo build --manifest-path Cargo.toml --bin openhuman-core — with a warm target, cargo run starts the binary almost immediately and the 180s budget is plenty","Run once with --verbose to stream the core's stdout/stderr and see whether it is compiling, booting, or stuck","Verify the port in --core-url matches what the core logs as its listen port (startCore passes OPENHUMAN_CORE_PORT derived from that URL — keep them consistent)","If boot itself is slow (migrations, first-run setup), let one run complete to warm the workspace, then subsequent runs start fast"],"exampleFix":"# before\n$ node scripts/debug/agent-prepare-context-audit.mjs --spawn-core\nError: timed out waiting for spawned core at http://127.0.0.1:7788/rpc\n\n# after (warm the build cache first so cargo run skips compilation)\n$ cargo build --manifest-path Cargo.toml --bin openhuman-core\n$ node scripts/debug/agent-prepare-context-audit.mjs --spawn-core","handlingStrategy":"retry","validationCode":"// Make the wait unnecessary: verify a warm binary exists before spawning\nimport { existsSync } from \"node:fs\";\nconst bin = \"target/debug/openhuman-core\";\nif (!existsSync(bin)) {\n  console.error(\"cold target — building first so the 180s startup wait isn't spent compiling\");\n  spawnSync(\"cargo\", [\"build\", \"--manifest-path\", \"Cargo.toml\", \"--bin\", \"openhuman-core\"], { stdio: \"inherit\" });\n}","typeGuard":null,"tryCatchPattern":"try {\n  await waitForCore(coreUrl, token, child, () => stderr);\n} catch (e) {\n  if (/timed out waiting for spawned core/.test(e.message)) {\n    // child still alive = probably still compiling; check target/ freshness and try once more\n    if (stillCompiling()) { console.error(\"build was cold — binary now warm, retrying\"); await waitForCore(coreUrl, token, child, () => stderr); }\n    else throw e;\n  } else throw e;\n}","preventionTips":["The 180s window includes the cargo build — pre-warm target/ with cargo build before every --spawn-core session","Derive the port only from --core-url (as startCore does) so the polled URL and the bound port can never disagree","First run in a fresh workspace is the slowest (migrations/setup); let one run complete to warm it before tuning timeouts"],"tags":["timeout","startup","build","process"],"backgroundTag":null,"analyzedSha":"a221052e0df5b1f7598fceba7329fd1af95d6699","analyzedAt":"2026-08-16T12:47:06.542Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}