jackwener/OpenCLI · error · TimeoutError

ChatWise response

Error message

ChatWise response

What it means

ChatWise's ask command polls the page for the assistant's reply until the response text stops changing; this TimeoutError is thrown when the extracted response is still empty after the --timeout window expires, meaning ChatWise never produced any text in time. It exists to fail fast instead of returning an empty transcript.

Source

Thrown at clis/chatwise/ask.js:47

        if (!injected)
            throw selectorError('ChatWise input element');
        await page.wait(0.5);
        await page.pressKey('Enter');
        // Poll for response
        const pollInterval = 2;
        const maxPolls = Math.ceil(timeout / pollInterval);
        let response = '';
        for (let i = 0; i < maxPolls; i++) {
            await page.wait(pollInterval);
            const result = await page.evaluate(buildChatwiseResponseAfterJs(beforeLen, text));
            if (result) {
                const next = String(result).trim();
                if (next === response) break;
                response = next;
            }
        }
        if (!response) {
            throw new TimeoutError('ChatWise response', timeout, 'Confirm ChatWise is done generating, then retry with a larger --timeout if needed.');
        }
        return [
            { Role: 'User', Text: text },
            { Role: 'Assistant', Text: response },
        ];
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Retry with a larger --timeout value (e.g. --timeout 120) once ChatWise has finished generating.
  2. Confirm ChatWise is actually generating a reply and the tab/page is responsive.
  3. Verify the DOM selector for the assistant response still matches the current ChatWise UI version.
  4. Pre-warm the ChatWise session/page before submitting the prompt to cut load time out of the timeout window.

Example fix

// before
clis chatwise ask "explain X" --timeout 10
// after
clis chatwise ask "explain X" --timeout 120
Defensive patterns

Strategy: retry

Validate before calling

const timeout = Number.parseInt(process.env.CHATWISE_TIMEOUT ?? '60', 10);
if (!(timeout > 0)) throw new Error('CHATWISE_TIMEOUT must be a positive integer');

Type guard

function isValidTimeout(v) { return Number.isInteger(v) && v > 0; }

Try / catch

try {
  const transcript = await chatwiseAsk(text, { timeout });
} catch (err) {
  if (err instanceof TimeoutError) {
    // retry once with a doubled timeout
    transcript = await chatwiseAsk(text, { timeout: timeout * 2 });
  } else throw err;
}

Prevention

When it happens

Trigger: Calling the ChatWise ask flow with a --timeout (in seconds) that expires before the assistant message selector yields any non-empty text; e.g. a slow/large generation, a page that hasn't finished loading the composer, or a stuck ChatWise tab.

Common situations: Long prompts with big answers exceeding the default timeout; slow machine/network where rendering lags; ChatWise UI changes so the selector never matches; user forgot to pass a larger --timeout.

Related errors


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