Hmbown/CodeWhale · error · anyhow::Error
Command timed out after {}ms
Error message
Command timed out after {}ms What it means
When the exec child outlives its timeout budget, the runner kills it (kill + wait) and bails with the elapsed limit in milliseconds. Output already streamed is kept; the kill guarantees the run terminates instead of hanging forever.
Source
Thrown at crates/tui/src/lib.rs:9133
print!("{}", String::from_utf8_lossy(&stdout));
}
if !stderr.is_empty() {
eprint!("{stderr_str}");
}
if sandbox_denied {
eprintln!(
"{}",
SandboxManager::denial_message(sandbox_type, &stderr_str)
);
}
if !status.success() {
bail!("Command failed with exit code {exit_code}");
}
} else {
let _ = child.kill();
let _ = child.wait();
bail!("Command timed out after {}ms", timeout.as_millis());
}
Ok(())
}
fn parse_sandbox_policy(
policy: &str,
network: bool,
writable_root: Vec<PathBuf>,
exclude_tmpdir: bool,
exclude_slash_tmp: bool,
) -> Result<crate::sandbox::SandboxPolicy> {
use crate::sandbox::SandboxPolicy;
match policy {
"danger-full-access" => Ok(SandboxPolicy::DangerFullAccess),
"read-only" => Ok(SandboxPolicy::ReadOnly),
"external-sandbox" => Ok(SandboxPolicy::ExternalSandbox {
network_access: network,View on GitHub (pinned to 0c42157ee5)
Solutions
- Raise the timeout (see the exec command's --help for the exact flag) to fit the workload
- Replace watch/serve-style commands with bounded ones (build instead of dev)
- Find the hang: run the command bare under `timeout 30 ...` and inspect where it stalls
- Give hanging prompts a non-interactive flag (--yes, CI=true) or feed stdin
Example fix
# before codewhale exec -- npm run dev # Command timed out after 30000ms # after codewhale exec --timeout 300000 -- npm run build # bounded workload (flag name per --help)
Defensive patterns
Strategy: retry
Validate before calling
# gauge runtime before granting a budget timeout 15 "$CMD" >/dev/null 2>&1; rc=$? [ $rc -eq 124 ] && echo 'command exceeds 15s -- raise exec timeout' >&2
Try / catch
match run_sandboxed_exec(cmd, policy, timeout) {
Err(e) if e.to_string().contains("Command timed out") => {
// re-run ONCE with a larger budget; a deterministic hang will not fix itself
run_sandboxed_exec(cmd, policy, timeout * 4)
}
other => other,
} Prevention
- Never run watch/serve commands under a bounded exec; use one-shot equivalents
- Set explicit generous timeouts in CI rather than relying on defaults
- Give interactive tools a non-interactive flag so they cannot block on stdin
When it happens
Trigger: Watch-mode or server commands (npm run dev, --watch flags) under exec; tests hanging on network or a missing TTY prompt; a timeout left at default while the workload legitimately needs longer.
Common situations: Long builds in CI with tight defaults; interactive prompts blocking forever in non-interactive runs; flaky external dependencies stalling the command.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- Command failed with exit code {exit_code}
- `codewhale --continue` resumes the interactive TUI. Use `cod
- {flag} must be placed before `exec`. Use: codewhale {flag
- git worktree add failed for branch {} at {}{}{}
- MCP server '{server}': {method} timed out after {timeout:?}
AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20).
Data as JSON: /api/errors/d13d75f545f60536.
Report an issue: GitHub.