{"record":{"id":"e2147e7366f4bd31","repo":"xai-org/grok-build","slug":"command-timed-out-after-s","errorCode":null,"errorMessage":"command timed out after {}s","messagePattern":"command timed out after (.+?)s","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-shell/src/auth/auth_provider.rs","lineNumber":324,"sourceCode":"        let (out_res, err_res) = tokio::join!(\n            read_capped(stdout, PROVIDER_STDOUT_CAP_BYTES + 1, &mut out_buf),\n            read_capped(stderr, PROVIDER_STDERR_CAP_BYTES, &mut err_buf),\n        );\n        if let Err(e) = err_res {\n            tracing::debug!(error = %e, \"auth provider: stderr capture failed (advisory)\");\n        }\n        out_res.map_err(|e| anyhow::anyhow!(\"reading command stdout: {e}\"))?;\n        child\n            .wait()\n            .await\n            .map_err(|e| anyhow::anyhow!(\"waiting on command: {e}\"))\n    };\n\n    let status = match tokio::time::timeout(timeout, capture).await {\n        Ok(res) => res?,\n        Err(_elapsed) => {\n            let _ = group.kill();\n            anyhow::bail!(\"command timed out after {}s\", timeout.as_secs());\n        }\n    };\n    if out_buf.len() as u64 > PROVIDER_STDOUT_CAP_BYTES {\n        anyhow::bail!(\"command wrote more than {PROVIDER_STDOUT_CAP_BYTES} bytes to stdout\");\n    }\n    Ok(std::process::Output {\n        status,\n        stdout: out_buf,\n        stderr: err_buf,\n    })\n}\n\nfn resolve_program(command: &str, cwd: Option<&std::path::Path>) -> std::path::PathBuf {\n    let path = std::path::Path::new(command);\n    if path.is_absolute() {\n        return path.to_path_buf();\n    }\n    if path.components().count() > 1","sourceCodeStart":306,"sourceCodeEnd":342,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-shell/src/auth/auth_provider.rs#L306-L342","documentation":"run_capped executes a provider auth command under tokio::time::timeout, capturing stdout/stderr. If the command does not finish within the timeout, the process group is killed and this error reports the timeout in seconds. It fails fast so token minting doesn't hang the shell.","triggerScenarios":"Calling mint_provider_token (via run_capped) when the configured provider credential command (e.g. a CLI that mints tokens) takes longer than the timeout — tokio::time::timeout fires and the process group is killed.","commonSituations":"Provider CLI prompting interactively for login on stdin (no TTY available), credential-helper scripts doing slow network calls, DNS hangs, or a mistakenly set very small timeout.","solutions":["Run the provider's login/refresh flow manually first so the command no longer prompts","Ensure the command runs non-interactively (env vars/API keys set, CI mode flags)","Raise the timeout passed to mint_provider_token if the command is legitimately slow","Check network reachability of the provider's auth endpoint from this host"],"exampleFix":"// before\nlet output = run_capped(&mut cmd, Duration::from_secs(5)).await?;\n// after\nlet output = run_capped(&mut cmd, Duration::from_secs(30)).await?;","handlingStrategy":"fallback","validationCode":"// Pre-check the command can run non-interactively\nif which::which(\"provider-cli\").is_err() {\n    anyhow::bail!(\"provider CLI not on PATH; login flow would hang/timeout\");\n}","typeGuard":null,"tryCatchPattern":"match mint_provider_token(&mut cmd, timeout).await {\n    Ok(tok) => tok,\n    Err(e) if e.to_string().contains(\"timed out\") => {\n        eprintln!(\"provider command hung; run its login flow interactively first\");\n        return Err(e);\n    },\n    Err(e) => return Err(e),\n}","preventionTips":["Always complete interactive provider login before automated use","Provision credentials via env/API key so no subprocess prompting occurs","Set timeouts generously but bounded; alert on repeated timeouts"],"tags":["timeout","subprocess","auth","command"],"backgroundTag":"command-timed-out","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}