JuliusBrussee/caveman · error

caveman agent: Cave Runtime did not become ready at

Error message

caveman agent: Cave Runtime did not become ready at ${gatewayURL}; run caveman setup --install

What it means

After spawning the Cave Runtime daemon, the agent polls runtimeReady(gatewayURL) until a deadline. If the runtime never becomes ready in time (and no startup failure surfaced), it throws this error advising 'caveman setup --install'. It means the gateway endpoint is not answering readiness checks after the start attempt.

Solutions

  1. Run 'caveman setup --install' to complete installation/configuration of the runtime
  2. Check whether anything else is bound to the gateway port and free it, then retry
  3. Start the runtime manually ('caveman start') to observe its errors, since the daemon's stdio is ignored
  4. Verify the gateway URL/port used by the agent matches the port the runtime actually listens on
Defensive patterns

Strategy: retry

Validate before calling

const deadline = Date.now() + 30_000;
while (Date.now() < deadline) {
  if (await isReady(gatewayURL)) break;
  await new Promise(r => setTimeout(r, 100));
}

Try / catch

try {
  await startCaveRuntime();
} catch (e) {
  if (String(e.message).includes('did not become ready')) {
    console.error('Run: caveman setup --install');
  } else throw e;
}

Prevention

When it happens

Trigger: Spawning 'caveman start' then polling /health/ready every 100ms until the deadline expires without a successful readiness response from gatewayURL.

Common situations: Runtime daemon crashed silently at startup (stdio is ignored so output is lost); port occupied by another process; gateway installed but never configured; very slow host exceeding the readiness deadline; firewall blocking the local port.

Understand the failure class

Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/5250ccaac965f073. Report an issue: GitHub.

Appendix: source

Thrown at packages/agent/src/runtime.ts:5269

        "caveman agent: Caveman CLI not found; run npm install, then caveman setup --install",
      )
      : new Error(`caveman agent: Cave Runtime failed to start (${error.message})`);
  });
  child.once("exit", (code, signal) => {
    if (startupFailure !== undefined || code === 0) return;
    startupFailure = new Error(
      `caveman agent: Cave Runtime failed to start (caveman start exited ${signal ?? code}); run caveman setup --install`,
    );
  });
  child.unref();
  const deadline = Date.now() + 10_000;
  while (Date.now() < deadline) {
    await new Promise((resolve) => setTimeout(resolve, 100));
    if (startupFailure !== undefined) throw startupFailure;
    const startedBilling = await runtimeReady(gatewayURL, fetchImpl);
    if (startedBilling !== undefined) return startedBilling;
  }
  throw new Error(
    `caveman agent: Cave Runtime did not become ready at ${gatewayURL}; run caveman setup --install`,
  );
}

async function runtimeReady(
  gatewayURL: string,
  fetchImpl: typeof globalThis.fetch,
): Promise<GatewayProviderBilling | undefined> {
  const identity = await gatewayIdentity(gatewayURL, fetchImpl);
  if (identity === undefined) return undefined;
  return await localProxyOwned(new URL(gatewayURL)) ? identity.providerBilling : undefined;
}

// A gateway hostname is loopback only if the traffic can never leave the host.
// WHATWG URL returns IPv6 literals bracketed ("[::1]"), so both forms are
// checked; 127.0.0.0/8 and 0.0.0.0 all route to localhost and must not be
// treated as remote (nor as needing https).
function isLoopbackHostname(hostname: string): boolean {

View on GitHub (pinned to 3ee70a1026)