{"record":{"id":"aca3d6d304738c95","repo":"Hmbown/CodeWhale","slug":"runtime-api-bridge-exited-before-becoming-ready-s","errorCode":null,"errorMessage":"runtime API bridge exited before becoming ready (status {status})","messagePattern":"runtime API bridge exited before becoming ready \\(status (.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/app-server/src/lib.rs","lineNumber":1584,"sourceCode":"            .arg(port.to_string())\n            .env(\"CODEWHALE_RUNTIME_TOKEN\", auth_token)\n            .env(\"DEEPSEEK_RUNTIME_TOKEN\", auth_token)\n            .stdin(Stdio::null())\n            .stdout(Stdio::null())\n            .stderr(Stdio::null());\n        if let Some(config_path) = config_path {\n            command.arg(\"--config\").arg(config_path);\n        }\n        Ok(command)\n    }\n\n    async fn wait_until_ready(&mut self) -> Result<()> {\n        let deadline = Instant::now() + Duration::from_secs(15);\n        loop {\n            if let Some(child) = self.child.as_mut()\n                && let Some(status) = child.try_wait()?\n            {\n                return Err(anyhow!(\n                    \"runtime API bridge exited before becoming ready (status {status})\"\n                ));\n            }\n\n            match self\n                .client\n                .get(format!(\"{}/health\", self.base_url))\n                .send()\n                .await\n            {\n                Ok(response) if response.status().is_success() => return Ok(()),\n                _ if Instant::now() >= deadline => {\n                    bail!(\n                        \"timed out waiting for runtime API bridge at {}/health\",\n                        self.base_url\n                    )\n                }\n                _ => tokio::time::sleep(Duration::from_millis(50)).await,","sourceCodeStart":1566,"sourceCodeEnd":1602,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/app-server/src/lib.rs#L1566-L1602","documentation":"Thrown by `wait_until_ready` while polling the spawned runtime API bridge child process. Before each readiness probe the method calls `child.try_wait()`; if the child has already terminated with `status`, it is impossible for it to become ready, so the error is returned immediately rather than waiting out the 15-second deadline. It reports the OS exit status of the premature exit.","triggerScenarios":"Starting the runtime API bridge and awaiting readiness when the child binary crashes, exits with a nonzero code, or terminates during startup within the 15-second readiness window.","commonSituations":"A broken or missing bridge binary, bad port/arguments, crash at startup due to config errors, OOM kill, or a dependency failing on the child side; environment issues where the runtime cannot initialize.","solutions":["Inspect the bridge process's stderr/stdout logs to find why it exited before becoming ready (status shows the exit code).","Run the bridge binary manually with the same arguments to reproduce the startup failure.","Verify the bridge executable path, permissions, and required environment (config, ports) are correct.","Retry once transient resource issues (OOM, port conflicts) are ruled out."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Verify the bridge binary exists and is executable before spawning\nassert!(std::path::Path::new(&bridge_path).exists(), \"bridge binary missing\");","typeGuard":null,"tryCatchPattern":"match wait_until_ready(&mut bridge).await {\n    Err(e) if e.to_string().contains(\"exited before becoming ready\") => {\n        // capture child stderr logs, then retry with a bounded backoff\n    }\n    other => other?,\n}","preventionTips":["Always pipe bridge stderr to a log file so premature exits are diagnosable","Smoke-test the bridge binary at startup (version/health subcommand)","Check port availability and required env before spawning","Use bounded retries on startup"],"tags":["process","startup","child-process"],"backgroundTag":"process-exited-before-ready","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}