jackwener/OpenCLI · error · CommandExecutionError

coingecko global request failed: ${err?.message ?? err}

Error message

coingecko global request failed: ${err?.message ?? err}

What it means

This CommandExecutionError wraps any network-level failure of the fetch() call to https://api.coingecko.com/api/v3/global — DNS failure, connection refused, TLS error, or abort. The underlying error message (e.g. ENOTFOUND, ECONNREFUSED) is embedded in the thrown message for diagnosis.

Source

Thrown at clis/coingecko/global.js:28

    description: 'Aggregate crypto market stats: total market cap, volume, dominance',
    domain: 'api.coingecko.com',
    strategy: Strategy.PUBLIC,
    browser: false,
    args: [
        { name: 'currency', type: 'string', default: 'usd', help: 'Quote currency for total market cap / volume (usd, cny, eur, jpy, ...)' },
    ],
    columns: ['currency', 'totalMarketCap', 'totalVolume24h', 'marketCapChange24hPct', 'btcDominancePct', 'ethDominancePct', 'activeCryptocurrencies', 'markets', 'ongoingIcos', 'updatedAt'],
    func: async (args) => {
        const currency = String(args.currency ?? 'usd').trim().toLowerCase();
        if (!/^[a-z0-9-]{2,20}$/.test(currency)) {
            throw new ArgumentError(`coingecko currency must look like a currency slug (got "${args.currency}")`);
        }
        let resp;
        try {
            resp = await fetch('https://api.coingecko.com/api/v3/global', { headers: { 'User-Agent': 'Mozilla/5.0' } });
        }
        catch (err) {
            throw new CommandExecutionError(`coingecko global request failed: ${err?.message ?? err}`);
        }
        if (resp.status === 429) {
            throw new CommandExecutionError(
                'coingecko returned HTTP 429 (rate limited)',
                'Free tier allows ~30 calls/min. Wait and retry.',
            );
        }
        if (!resp.ok) {
            throw new CommandExecutionError(`coingecko global returned HTTP ${resp.status}`);
        }
        let body;
        try {
            body = await resp.json();
        }
        catch (err) {
            throw new CommandExecutionError(`coingecko global returned malformed JSON: ${err?.message ?? err}`);
        }
        const data = body?.data;

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Verify reachability: `curl -I https://api.coingecko.com/api/v3/ping`.
  2. Fix DNS/proxy settings (HTTPS_PROXY, corporate allowlist for api.coingecko.com) and retry.
  3. Use the embedded cause message (ENOTFOUND vs ECONNREFUSED vs CERT errors) to target the specific network issue.
  4. Add retry with backoff for transient connectivity blips in automation.
  5. Run from an environment with internet egress if fully firewalled.
Defensive patterns

Strategy: retry

Try / catch

try {
  await globalCmd.func({ currency: 'usd' });
} catch (e) {
  if (/coingecko global request failed/.test(e.message)) {
    await sleep(2000);
    return withRetry(() => globalCmd.func({ currency: 'usd' }), 3);
  }
  throw e;
}

Prevention

When it happens

Trigger: fetch() throws before receiving a response: no internet access, DNS cannot resolve api.coingecko.com, firewall/proxy blocking the host, TLS interception failure, or the request being aborted.

Common situations: Air-gapped or offline environments, CI runners without egress, corporate proxies, VPN disconnections, or Docker/K8s DNS misconfiguration.

Related errors


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