{"record":{"id":"5094a7f94cd588aa","repo":"Hmbown/CodeWhale","slug":"cloud-agent-sandbox-was-not-ready-in-time","errorCode":null,"errorMessage":"Cloud agent sandbox was not ready in time.","messagePattern":"Cloud agent sandbox was not ready in time\\.","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/cloud_dispatch.rs","lineNumber":1625,"sourceCode":"                            \"error\" | \"destroyed\" | \"archived\" => {\n                                bail!(\"Cloud agent sandbox entered state '{state}'.\");\n                            }\n                            _ => {}\n                        }\n                    } else {\n                        return Ok(());\n                    }\n                }\n                Err(error) => return Err(error),\n                Ok(response) => {\n                    if response.status().as_u16() == 404 {\n                        bail!(\"Cloud agent sandbox disappeared before it was ready.\");\n                    }\n                }\n            }\n            std::thread::sleep(READY_POLL_INTERVAL);\n        }\n        bail!(\"Cloud agent sandbox was not ready in time.\");\n    }\n\n    fn clone_repository(&self, receipt: &SandboxReceipt, repo_url: &str, path: &str) -> Result<()> {\n        let repo_url = validate_git_remote_url(repo_url)?;\n        let api_key = Self::api_key()?;\n        let url = Self::toolbox_base(receipt)?.join(\"git/clone\")?;\n        let body = serde_json::json!({ \"url\": repo_url, \"path\": path });\n        let response = Self::send_json(reqwest::Method::POST, &url, &api_key, body)?;\n        let status = response.status();\n        if !status.is_success() {\n            bail!(\"Cloud agent repository clone failed (HTTP {status}).\");\n        }\n        Ok(())\n    }\n\n    fn run_harness(&self, receipt: &SandboxReceipt, command: &HarnessCommand) -> Result<String> {\n        let api_key = Self::api_key()?;\n        let url = Self::toolbox_base(receipt)?.join(\"process/execute\")?;","sourceCodeStart":1607,"sourceCodeEnd":1643,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/cloud_dispatch.rs#L1607-L1643","documentation":"Thrown by `wait_ready` in the cloud sandbox provider after the sandbox was created but never reached the `started`/`ready` state within `READY_POLL_ATTEMPTS` polling iterations spaced by `READY_POLL_INTERVAL`. The control plane kept returning a non-success, non-404 response (or an unparseable body with a non-terminal state such as `provisioning`), so the dispatcher gives up rather than waiting forever. This is a provisioning-timeout condition, not an authentication or request-shape failure.","triggerScenarios":"Calling the cloud-agent dispatch path that provisions a sandbox (e.g. starting a cloud job or raising a PR) when the provider's control plane keeps reporting the sandbox in a non-ready state: `GET sandbox/{id}` repeatedly returns 5xx, 429, or a JSON body whose `state` is still provisioning/booting for the entire poll window. Terminal states (`error`, `destroyed`, `archived`) and a 404 bail earlier with distinct messages.","commonSituations":"Provider outage or degraded region at Daytona; sandbox image pulls are slow (large image, cold cache); provider capacity shortage leaving the sandbox queued; network flakiness between the client and the control plane producing intermittent 5xx during every poll; provider slowed state transitions after an API version change.","solutions":["Retry the cloud job — sandbox provisioning is often transiently slow; a fresh attempt usually gets a healthy sandbox.","Check the provider (Daytona) status/region health and your quota; reduce load or switch region if the sandbox is stuck provisioning.","Inspect the sandbox by id in the provider dashboard; if it exists but is stuck, delete it manually before retrying so the next dispatch starts clean.","If timeouts are consistently near-miss, increase READY_POLL_ATTEMPTS or READY_POLL_INTERVAL in crates/tui/src/cloud_dispatch.rs for slower-provisioning accounts/images."],"exampleFix":"// before\nfor _ in 0..READY_POLL_ATTEMPTS {\n    // poll ...\n    std::thread::sleep(READY_POLL_INTERVAL);\n}\nbail!(\"Cloud agent sandbox was not ready in time.\");\n// after\n// rerun the job; if it recurs, raise the poll budget:\nconst READY_POLL_ATTEMPTS: usize = 120;\nconst READY_POLL_INTERVAL: Duration = Duration::from_secs(5);","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// the sandbox may simply need longer; retry the whole dispatch with backoff\nmatch dispatch_cloud_job(job) {\n    Err(e) if e.to_string().contains(\"not ready in time\") => retry_with_backoff(job, 2),\n    other => other,\n}","preventionTips":["Retry cloud jobs automatically once before surfacing the error to the user.","Monitor provider status pages and avoid dispatching during known incidents.","Right-size READY_POLL_ATTEMPTS/READY_POLL_INTERVAL for your image's cold-start time.","Keep images small and pre-cached in the target region to shorten provisioning."],"tags":["cloud","sandbox","provisioning-timeout","polling"],"backgroundTag":"request-timeout","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"}