{"record":{"id":"46f5084fe9f2c501","repo":"google-gemini/gemini-cli","slug":"command-command-timed-out-after-command-tim","errorCode":null,"errorMessage":"Command '${command}' timed out after ${COMMAND_TIMEOUT_MS / 1000} seconds","messagePattern":"Command '(.+?)' timed out after (.+?) seconds","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/agents/auth-provider/value-resolver.ts","lineNumber":74,"sourceCode":"    const shellConfig = getShellConfiguration();\n    try {\n      const { stdout } = await spawnAsync(\n        shellConfig.executable,\n        [...shellConfig.argsPrefix, command],\n        {\n          signal: AbortSignal.timeout(COMMAND_TIMEOUT_MS),\n          windowsHide: true,\n        },\n      );\n\n      const trimmed = stdout.trim();\n      if (!trimmed) {\n        throw new Error(`Command '${command}' returned empty output`);\n      }\n      return trimmed;\n    } catch (error) {\n      if (error instanceof Error && error.name === 'AbortError') {\n        throw new Error(\n          `Command '${command}' timed out after ${COMMAND_TIMEOUT_MS / 1000} seconds`,\n        );\n      }\n      throw error;\n    }\n  }\n\n  // Literal value - return as-is\n  return value;\n}\n\n/**\n * Check if a value needs resolution (is an env var or command reference).\n */\nexport function needsResolution(value: string): boolean {\n  return value.startsWith('$') || value.startsWith('!');\n}\n","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/google-gemini/gemini-cli/blob/5024443c7217464a66e98f80d73172a26440bd8f/packages/core/src/agents/auth-provider/value-resolver.ts#L56-L92","documentation":"Thrown by resolveAuthValue when the spawned shell command exceeded COMMAND_TIMEOUT_MS (60000ms / 60s). The AbortSignal.timeout aborts spawnAsync; the catch detects error.name === 'AbortError' and re-wraps it with this message.","triggerScenarios":"resolveAuthValue('!cmd') where cmd takes longer than 60 seconds. spawnAsync receives AbortSignal.timeout(60_000); on abort the AbortError is caught and converted to a domain-specific timeout error.","commonSituations":"Command prompts for input interactively (password / MFA) and blocks forever waiting on a TTY that is not present; command makes a slow network call (e.g. a cloud metadata or STS call behind a slow link); command is waiting on a lock; command shells out to a daemon that is hung.","solutions":["Run the command standalone and time it; if it is genuinely slow, cache its output into an env var instead.","Ensure the command is non-interactive: pass flags that suppress prompts (--no-input, batch mode) or pre-seed credentials.","Check for a stale lock or hung daemon the command depends on and restart it.","If 60s is insufficient for a legitimate slow command, pre-resolve the value into an environment variable and reference it with $VAR instead."],"exampleFix":"# before: interactive prompt hangs\naccessToken: '!aws sts get-session-token ...'  # prompts for MFA, blocks\n\n# after: non-interactive, cached\nexport TOKEN=$(aws sts get-session-token --token-code 123456 --query Credentials.SessionToken --output text)\naccessToken: '$TOKEN'","handlingStrategy":"retry","validationCode":"// Pre-flight timing check.\nimport { spawnSync } from 'node:child_process';\nfunction isCmdFastEnough(cmd, limitMs = 55_000) {\n  const t0 = Date.now();\n  spawnSync(cmd, { shell: true, timeout: limitMs });\n  return Date.now() - t0 < limitMs;\n}","typeGuard":null,"tryCatchPattern":"try {\n  const val = await resolveAuthValue('!slow-cmd');\n} catch (e) {\n  if (e instanceof Error && /timed out/.test(e.message)) {\n    // switch to a cached env var, or make the command non-interactive\n  }\n  throw e;\n}","preventionTips":["Avoid interactive (prompting) commands in auth values.","Cache slow command output into an env var and reference via $VAR.","Pass non-interactive flags to credential helpers."],"tags":["auth","shell","timeout","config"],"backgroundTag":null,"analyzedSha":"5024443c7217464a66e98f80d73172a26440bd8f","analyzedAt":"2026-08-12T06:01:53.711Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}