{"record":{"id":"9c45910169b9f4fd","repo":"xai-org/grok-build","slug":"external-auth-provider-command-timed-out-after","errorCode":null,"errorMessage":"external auth provider `{command}` timed out after 300s","messagePattern":"external auth provider `(.+?)` timed out after 300s","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-shell/src/auth/flow.rs","lineNumber":240,"sourceCode":"                        tracing::debug!(line = trimmed, \"auth: provider stderr\");\n                        cb(trimmed);\n                    }\n                    Err(e) => {\n                        tracing::warn!(error = %e, \"auth: error reading provider stderr\");\n                        break;\n                    }\n                }\n            }\n        }))\n    } else {\n        None\n    };\n    let output = tokio::time::timeout(\n        std::time::Duration::from_secs(300),\n        child.wait_with_output(),\n    )\n    .await\n    .map_err(|_| anyhow::anyhow!(\"external auth provider `{command}` timed out after 300s\"))?\n    .map_err(|e| anyhow::anyhow!(\"external auth provider `{command}` IO error: {e}\"))?;\n    if let Some(task) = stderr_task {\n        let _ = task.await;\n    }\n    let mut auth = parse_output(&output)\n        .map_err(|e| anyhow::anyhow!(\"external auth provider `{command}`: {e}\"))?;\n    let principal_policy =\n        crate::auth::oidc::login_principal_policy(auth_manager.grok_com_config());\n    crate::auth::oidc::enforce_login_principal(\n        principal_policy.as_ref(),\n        crate::auth::oidc::peek_access_token_principal_id(&auth.key).as_deref(),\n    )?;\n    match (over_stale_credential, auth_manager.current_or_expired()) {\n        (true, Some(prev)) => auth.carry_user_profile_from(&prev),\n        _ => auth_manager.enrich_auth_inline(&mut auth).await,\n    }\n    let auth = auth_manager\n        .update(auth)","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-shell/src/auth/flow.rs#L222-L258","documentation":"After spawning the external auth provider, the flow waits up to 300 seconds for it to finish via tokio::time::timeout around wait_with_output(). If the child does not exit in 300s, the future is dropped (killing the wait) and this error is returned. It exists so a hung provider cannot hang the login flow forever.","triggerScenarios":"Running any auth flow with an external provider whose process runs longer than 300 seconds: it blocks on an interactive prompt that never gets input (e.g. a browser-based or stdin-based handshake with no TTY), or is simply stuck.","commonSituations":"Non-interactive/CI runs where the provider waits for a browser OAuth callback that never arrives; provider waiting on stdin with no TTY; network stall inside the provider; provider hangs opening a port already in use for the callback.","solutions":["Run the provider command manually with the same inputs to see where it blocks; fix the provider's blocking step.","For headless environments, configure the provider for non-interactive mode (device-code flow or pre-fetched token).","Check the callback port is not occupied and that browsers/loopback access works if the provider waits for an OAuth redirect.","Wrap/widen any provider-side timeout so it exits on its own with a clear error before 300s."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// before login, confirm the provider can run non-interactively\nprovider_cmd --check || echo 'provider hangs or needs a TTY'","typeGuard":null,"tryCatchPattern":"match run_auth_flow(...).await {\n    Err(e) if e.to_string().contains(\"timed out after 300s\") => {\n        eprintln!(\"Provider hung; run it manually to find the blocking step, then retry\");\n    }\n    other => other?,\n}","preventionTips":["Make the provider fail fast instead of waiting on input","Use device-code or pre-fetched tokens in headless environments","Ensure the OAuth callback port is free","Add provider-side internal timeouts well below 300s"],"tags":["auth","timeout","external-provider","process"],"backgroundTag":"process-timeout","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}