jackwener/OpenCLI · error · TimeoutError

weread-official ${apiName}

Error message

weread-official ${apiName}

What it means

callGateway wraps fetch failures in two typed errors: TimeoutError when the request was aborted by the configured AbortController (timeoutMs elapsed), and CommandExecutionError otherwise. The message carries the api name so you know which endpoint failed. It exists to convert low-level network errors into actionable CLI errors.

Source

Thrown at clis/weread-official/utils.js:95

    const controller = new AbortController();
    const timer = setTimeout(() => controller.abort(), timeoutMs);

    let response;
    try {
        response = await fetch(WEREAD_GATEWAY_URL, {
            method: 'POST',
            headers: {
                Authorization: `Bearer ${key}`,
                'Content-Type': 'application/json',
            },
            body: JSON.stringify(body),
            signal: controller.signal,
        });
    }
    catch (error) {
        if (error?.name === 'AbortError') {
            throw new TimeoutError(`weread-official ${apiName}`, Math.round(timeoutMs / 1000));
        }
        const detail = error instanceof Error ? error.message : String(error);
        throw new CommandExecutionError(`weread-official ${apiName} request failed`, detail);
    }
    finally {
        clearTimeout(timer);
    }

    if (!response.ok) {
        throw new CommandExecutionError(
            `weread-official ${apiName} HTTP ${response.status}`,
            'Check WeRead gateway availability and that WEREAD_API_KEY is still valid.',
        );
    }

    let payload;
    try {
        payload = await response.json();

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Check basic network connectivity and proxy settings (HTTP_PROXY/HTTPS_PROXY).
  2. Retry the command — transient timeouts often resolve; consider increasing the timeout.
  3. Verify https://weread.<domain> gateway status/outage.
  4. If running in CI, add egress rules for the gateway domain.
Defensive patterns

Strategy: retry

Validate before calling

if (!navigator.onLine && typeof navigator !== 'undefined') throw new Error('No network connectivity before calling gateway');

Type guard

const isAbort = (e) => e?.name === 'AbortError';

Try / catch

try {
  return await callGateway(apiName, params);
} catch (e) {
  if (e instanceof TimeoutError) {
    // exponential backoff, max 3 attempts
    await sleep(2 ** attempt * 1000);
    return callGateway(apiName, params);
  }
  if (e instanceof CommandExecutionError) console.error(`Gateway request failed: ${e.message}`);
  throw e;
}

Prevention

When it happens

Trigger: Any fetch exception inside callGateway: AbortError raised after timeoutMs (message becomes 'weread-official <apiName>'), or DNS failure / connection refused / TLS error (detail carries the underlying message).

Common situations: Corporate proxy blocking the gateway; slow mobile connection exceeding the timeout; WEREAD gateway temporarily down; firewalled CI runners without egress.

Related errors


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