{"record":{"id":"33a8b78a650262ce","repo":"JuliusBrussee/caveman","slug":"caveman-trial-proxy-did-not-become-ready-on-host","errorCode":null,"errorMessage":"caveman trial proxy did not become ready on ${host}:${port}","messagePattern":"caveman trial proxy did not become ready on (.+?):(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cli/src/index.ts","lineNumber":16953,"sourceCode":"\nfunction freePort(): Promise<number> {\n  return new Promise((resolve, reject) => {\n    const server = netCreateServer();\n    server.on(\"error\", reject);\n    server.listen(0, \"127.0.0.1\", () => {\n      const addr = server.address() as AddressInfo;\n      server.close(() => resolve(addr.port));\n    });\n  });\n}\n\nasync function waitForPort(host: string, port: number, timeoutMs: number): Promise<void> {\n  const deadline = Date.now() + timeoutMs;\n  while (Date.now() < deadline) {\n    if (await portListening(host, port)) return;\n    await sleep(100);\n  }\n  throw new Error(`caveman trial proxy did not become ready on ${host}:${port}`);\n}\n\nfunction waitForChild(child: ReturnType<typeof spawn>, timeoutMs: number): Promise<void> {\n  return new Promise((resolve) => {\n    let done = false;\n    const finish = () => {\n      if (done) return;\n      done = true;\n      resolve();\n    };\n    child.once(\"exit\", finish);\n    child.once(\"close\", finish);\n    setTimeout(() => {\n      try { child.kill(\"SIGKILL\"); } catch {}\n      finish();\n    }, timeoutMs).unref();\n  });\n}","sourceCodeStart":16935,"sourceCodeEnd":16971,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/cli/src/index.ts#L16935-L16971","documentation":"`waitForPort` polls the trial proxy's host:port every 100ms until a timeout elapses. If the port never accepts connections within the deadline, the CLI concludes the trial proxy failed to start and throws this error.","triggerScenarios":"Starting the `caveman trial` flow when the spawned proxy process fails to bind its port (crash on startup, port blocked by firewall, wrong host, or startup slower than the timeout).","commonSituations":"Port already occupied or blocked by a firewall/VPN; proxy binary crashes immediately due to missing config; slow machine or container cold start exceeding the readiness timeout.","solutions":["Check the proxy process logs/stderr for a startup crash and fix the underlying cause (missing config, bad key).","Verify the host:port is reachable (`nc -z <host> <port>`) and that no firewall blocks the port.","Retry the trial command once to rule out transient slow startup; ensure the binary is installed/updated via `caveman setup --install`."],"exampleFix":"// before (shell)\ncaveman trial  # proxy listens on 127.0.0.1 but firewall blocks it\n// error: caveman trial proxy did not become ready on 127.0.0.1:8080\n// after (shell)\nsudo ufw allow 8080/tcp\ncaveman trial","handlingStrategy":"retry","validationCode":"// shell\nif ! nc -z 127.0.0.1 8080 2>/dev/null; then\n  echo \"trial port not listening; check proxy logs before retrying\"\nfi","typeGuard":null,"tryCatchPattern":"// js\ntry {\n  await startTrialProxy();\n} catch (e) {\n  if (String(e.message).includes(\"did not become ready\")) {\n    logProxyStderr();\n    await sleep(1000);\n    return startTrialProxy(); // retry once after surfacing child logs\n  }\n  throw e;\n}","preventionTips":["Ensure the chosen port is free and allowed by firewall/VPN before starting trials.","Check proxy child process stderr on every failed start.","Run trials on warm environments to avoid cold-start timeouts."],"tags":["network","proxy","timeout","startup"],"backgroundTag":"connection-refused","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}