{"record":{"id":"d236f05d3e436c79","repo":"tinyhumansai/openhuman","slug":"timed-out-waiting-for-core-at-coreurl-stderrf","errorCode":null,"errorMessage":"timed out waiting for core at ${coreUrl}\n${stderrFn()}","messagePattern":"timed out waiting for core at (.+?)\n(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/debug/goals-live.mjs","lineNumber":401,"sourceCode":"    });\n  }\n  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(`spawned core exited with ${child.exitCode}\\n${stderrFn()}`);\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(`timed out waiting for core at ${coreUrl}\\n${stderrFn()}`);\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), 5000)),\n  ]);\n  if (exited) return;\n  child.kill(\"SIGKILL\");\n  await Promise.race([once(child, \"exit\"), new Promise((r) => setTimeout(r, 2000))]);\n}\n\n// ── cases ───────────────────────────────────────────────────────────────────\n\nfunction call(opts, method, params = {}) {\n  return rpc(opts.coreUrl, opts.token, method, params, opts.rpcTimeoutMs);","sourceCodeStart":383,"sourceCodeEnd":419,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/a221052e0df5b1f7598fceba7329fd1af95d6699/scripts/debug/goals-live.mjs#L383-L419","documentation":"waitForCore() gives the spawned core 180 seconds to answer its first core.ping; if the deadline passes with the child still alive but silent, this error fires with the stderr tail. Unlike error 227 (child died), here the child runs but never serves RPC on the expected URL — overwhelmingly a cold-build problem: `cargo run` must compile the whole Rust core before the process even starts listening.","triggerScenarios":"First-ever (or after-clean) invocation: cargo compiles the core for >3 minutes while the script polls; incremental build after touching many crates; the child listens on a different port/path than opts.coreUrl (port parsing from the URL, proxy env vars redirecting 127.0.0.1); machine heavily loaded so compile+boot exceeds 180 s.","commonSituations":"Fresh clone running `pnpm debug goals-live -- --spawn-core` before any cargo build; CI runner or container with cold target/ cache; concurrently running another cargo build (lock contention); HTTPS_PROXY env capturing loopback fetches so ping never lands.","solutions":["Prebuild once, then rerun: `cargo build --manifest-path Cargo.toml --bin openhuman-core` (subsequent spawns start in seconds)","Rerun with --verbose to watch compile progress and confirm it is just slow","Ensure no proxy intercepts loopback: `NO_PROXY=127.0.0.1` env","Avoid competing cargo processes (release build, rust-analyzer full index) while spawning","On persistently slow machines, build separately and run the audit against the pre-started binary without --spawn-core"],"exampleFix":"# before: first run, cold target/\nnode scripts/debug/goals-live.mjs --spawn-core\n# Error: timed out waiting for core at http://127.0.0.1:XXXX/rpc\n\n# after: prebuild, then spawn (reuses compiled binary)\ncargo build --bin openhuman-core && node scripts/debug/goals-live.mjs --spawn-core","handlingStrategy":"fallback","validationCode":"// warm the binary before running the script: guarantees the 180s boot window is enough\nimport { spawnSync } from \"node:child_process\";\nconst built = spawnSync(\"cargo\", [\"build\", \"--quiet\", \"--bin\", \"openhuman-core\"], {\n  cwd: repoRoot, stdio: \"inherit\",\n});\nif (built.status !== 0) { console.error(\"core failed to build\"); process.exit(built.status ?? 1); }","typeGuard":null,"tryCatchPattern":"try {\n  await waitForCore(coreUrl, token, child, stderrFn);\n} catch (err) {\n  if (/timed out waiting for core/.test(err.message)) {\n    // fall back: kill the child, prebuild, retry once\n    await stopChild(child);\n    spawnSync(\"cargo\", [\"build\", \"--quiet\", \"--bin\", \"openhuman-core\"], { cwd: repoRoot, stdio: \"inherit\" });\n    return await startCore(opts); // second attempt starts in seconds\n  }\n  throw err;\n}","preventionTips":["Prebuild the core after every pull before using --spawn-core","Set NO_PROXY for 127.0.0.1 so the ping is not proxied","Avoid concurrent cargo invocations (release build, clippy) that serialize on the build lock"],"tags":["process","timeout","build","rust","cold-start"],"backgroundTag":null,"analyzedSha":"a221052e0df5b1f7598fceba7329fd1af95d6699","analyzedAt":"2026-08-16T12:47:06.542Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}