jackwener/OpenCLI · error · TimeoutError

grok ask response

Error message

grok ask response

What it means

The grok ask command throws a TimeoutError('grok ask response', timeoutSeconds) when waitForAnswer() neither completed nor made usable partial progress within the --timeout window (default 120s). Statuses 'ok' and 'partial' (streaming seen but never stabilized, with some assistant text) return the text; any other status — typically no assistant reply detected at all — becomes this timeout. It signals the prompt was sent but Grok never produced a retrievable answer in time.

Source

Thrown at clis/grok/ask.js:71

        const baselineLastAssistantId = await getBaselineLastAssistantId(page);
        const sendResult = await sendMessage(page, prompt);
        if (!sendResult || !sendResult.ok) {
            const reason = sendResult?.reason || 'Unable to send the prompt to Grok.';
            const detail = sendResult?.detail ? ` ${sendResult.detail}` : '';
            throw new CommandExecutionError(`${reason}${detail}`, SESSION_HINT);
        }

        const result = await waitForAnswer(page, prompt, timeoutSeconds, baselineLastAssistantId);
        if (result.status === 'ok') {
            return [{ response: result.assistant.text }];
        }
        // Partial: streaming was seen but did not stabilize; keep the best-effort
        // text rather than throwing — the caller asked us to wait, not to discard.
        if (result.status === 'partial' && result.assistant) {
            return [{ response: result.assistant.text }];
        }
        throw new TimeoutError('grok ask response', timeoutSeconds);
    },
});

export const __test__ = {
    getBaselineLastAssistantId,
};

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Increase the timeout: re-run with `--timeout 300` (or higher) for long generations.
  2. Retry the command — transient capacity/queue issues on grok.com often resolve on a second attempt.
  3. Start a fresh conversation with `--new` so a lingering previous response cannot confuse bubble detection.
  4. Verify the grok.com session is healthy (no challenge page, conversation actually created) and re-authenticate if needed.
  5. If it always times out instantly, waitForAnswer/bubble selectors in clis/grok/utils.js may be stale — update them to the current grok.com DOM.

Example fix

// before
grok ask "Write a 5000-word essay"
// after: allow a longer window for large generations
grok ask "Write a 5000-word essay" --timeout 300 --new
Defensive patterns

Strategy: retry

Try / catch

async function askWithRetry(prompt, { attempts = 3, timeout = 300 } = {}) {
  for (let i = 0; i < attempts; i++) {
    try {
      return await run('grok', 'ask', { prompt, timeout, new: i > 0 });
    } catch (e) {
      if (!(e instanceof TimeoutError) || i === attempts - 1) throw e;
      await new Promise(r => setTimeout(r, 2 ** i * 3000));
    }
  }
}

Prevention

When it happens

Trigger: Calling `grok ask "..."` where: (1) the assistant never started streaming within timeoutSeconds (long queue, model overloaded); (2) streaming started but result.assistant was null so the 'partial' branch is skipped; (3) the response exceeded the default 120s timeout on a very long generation; (4) waitForAnswer could not distinguish the new assistant bubble from the baseline (e.g. page navigated or DOM IDs changed); (5) the page hit a mid-conversation error and no assistant text appeared.

Common situations: Very long prompts or reasoning-model answers exceeding 120s; grok.com capacity issues making responses stall; slow/filtered network or headless-browser resource starvation; Grok UI changes breaking bubble detection; user leaving --timeout at default for heavy workloads.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/41dc4c68a2958a84. Report an issue: GitHub.