jackwener/OpenCLI · error · CommandExecutionError

coingecko coin request failed: ${error?.message || error}

Error message

coingecko coin request failed: ${error?.message || error}

What it means

This CommandExecutionError wraps any network-level failure of the fetch() call to api.coingecko.com — DNS resolution errors, connection refused/reset, TLS errors, or timeouts. The command makes a plain HTTPS GET with a browser User-Agent; if the request never gets an HTTP response, the underlying error message is interpolated into this message.

Source

Thrown at clis/coingecko/coin.js:51

        }
        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}")`);
        }

        const url = new URL(`https://api.coingecko.com/api/v3/coins/${id}`);
        url.searchParams.set('localization', 'false');
        url.searchParams.set('tickers', 'false');
        url.searchParams.set('market_data', 'true');
        url.searchParams.set('community_data', 'false');
        url.searchParams.set('developer_data', 'false');
        url.searchParams.set('sparkline', 'false');

        let resp;
        try {
            resp = await fetch(url, { headers: { 'User-Agent': 'Mozilla/5.0' } });
        } catch (error) {
            throw new CommandExecutionError(`coingecko coin request failed: ${error?.message || error}`);
        }
        if (resp.status === 404) {
            throw new EmptyResultError('coingecko coin', `coingecko has no coin with id "${id}".`);
        }
        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 coin failed: HTTP ${resp.status}`);
        }
        let data;
        try {
            data = await resp.json();
        } catch (error) {
            throw new CommandExecutionError(`coingecko returned malformed JSON: ${error?.message || error}`);
        }
        if (data?.error) {
            throw new CommandExecutionError(`coingecko returned error: ${data.error}`);

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Check network connectivity (e.g. `curl -I https://api.coingecko.com/api/v3/ping`)
  2. Check proxy/VPN/firewall settings and set HTTPS_PROXY if a corporate proxy is required
  3. Retry after transient network issues; consider adding timeout/retry logic around the CLI call

Example fix

// before
resp = await fetch(url, { headers: { 'User-Agent': 'Mozilla/5.0' } });
// after
resp = await fetch(url, { headers: { 'User-Agent': 'Mozilla/5.0' }, signal: AbortSignal.timeout(15000) }); // plus retry-once on failure
Defensive patterns

Strategy: retry

Validate before calling

const reachable = await fetch('https://api.coingecko.com/api/v3/ping', { signal: AbortSignal.timeout(5000) }).then(r => r.ok).catch(() => false);
if (!reachable) throw new Error('api.coingecko.com unreachable — check network/proxy');

Type guard

null

Try / catch

try { await run(['coingecko', 'coin', id]); } catch (e) { if (/request failed/.test(e.message)) { await sleep(2000); return retryOnce(); } throw e; }

Prevention

When it happens

Trigger: No internet connectivity; DNS failure resolving api.coingecko.com; firewall/proxy blocking the request; TLS interception; Node fetch socket timeout; IPv6 connectivity issues.

Common situations: Running the CLI in CI environments without network egress; corporate proxies that block or MITM api.coingecko.com; offline laptop; VPN dropping mid-call.

Related errors


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