jackwener/OpenCLI · error · CommandExecutionError

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

Error message

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

What it means

This CommandExecutionError wraps any failure of the fetch() call to the CoinGecko /derivatives ENDPOINT, embedding the underlying error message. It indicates the HTTP request never completed — DNS failure, connection refused/reset, TLS error, timeout, or offline network.

Source

Thrown at clis/coingecko/derivatives.js:41

        { name: 'limit', type: 'int', default: 20, help: 'Max rows to return (1-500; CoinGecko returns one large page).' },
        { name: 'symbol', type: 'string', required: false, help: 'Optional symbol substring filter (e.g. "BTC", "ETHUSDT").' },
    ],
    columns: ['rank', 'market', 'symbol', 'indexId', 'contractType', 'price', 'change24hPct', 'fundingRate', 'openInterestUsd', 'volume24hUsd', 'expired'],
    func: async (args) => {
        const limit = Number(args.limit ?? 20);
        if (!Number.isInteger(limit) || limit <= 0) {
            throw new ArgumentError('coingecko derivatives limit must be a positive integer');
        }
        if (limit > 500) {
            throw new ArgumentError('coingecko derivatives limit must be <= 500');
        }
        const filter = args.symbol == null ? '' : String(args.symbol).trim().toUpperCase();
        let resp;
        try {
            resp = await fetch(ENDPOINT, { headers: { 'User-Agent': 'Mozilla/5.0' } });
        }
        catch (err) {
            throw new CommandExecutionError(`coingecko derivatives request failed: ${err?.message ?? err}`);
        }
        if (resp.status === 429) {
            throw new CommandExecutionError(
                'coingecko derivatives returned HTTP 429 (rate limited)',
                'Free tier allows ~30 calls/min. Wait and retry.',
            );
        }
        if (!resp.ok) {
            throw new CommandExecutionError(`coingecko derivatives returned HTTP ${resp.status}`);
        }
        let data;
        try {
            data = await resp.json();
        }
        catch (err) {
            throw new CommandExecutionError(`coingecko derivatives returned malformed JSON: ${err?.message ?? err}`);
        }
        if (!Array.isArray(data) || !data.length) {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Check network connectivity and that https://api.coingecko.com is reachable (curl -I)
  2. Retry after a short wait — often transient
  3. Inspect the wrapped message for the root cause (ENOTFOUND, ECONNREFUSED, etc.) and fix DNS/proxy accordingly
  4. Configure proxy/HTTPS_PROXY env vars if behind a corporate firewall

Example fix

// before
resp = await fetch(ENDPOINT); // fails behind proxy
// after
// set HTTPS_PROXY / HTTP_PROXY env vars, then retry
resp = await fetch(ENDPOINT, { headers: { 'User-Agent': 'Mozilla/5.0' } });
Defensive patterns

Strategy: retry

Validate before calling

// Reachability pre-check (optional)
const ping = await fetch('https://api.coingecko.com/api/v3/ping').catch(() => null);
if (!ping) throw new Error('api.coingecko.com unreachable — check network/proxy/DNS');

Type guard

const isNetworkError = (err) => err instanceof TypeError || /ENOTFOUND|ECONNREFUSED|ECONNRESET|ETIMEDOUT|fetch failed/i.test(String(err?.cause?.code ?? err?.message ?? err));

Try / catch

try {
  resp = await fetch(ENDPOINT, { headers: { 'User-Agent': 'Mozilla/5.0' } });
} catch (err) {
  // transient network failure: retry with backoff
  for (let i = 0; i < 3; i++) {
    await new Promise(r => setTimeout(r, 2 ** i * 1000));
    try { resp = await fetch(ENDPOINT); break; } catch (_) {}
  }
  if (!resp) throw new Error(`coingecko derivatives request failed: ${err?.message ?? err}`);
}

Prevention

When it happens

Trigger: Network outage or no DNS resolution, CoinGecko unreachable/firewalled, TLS interception, IPv6 issues, request aborted by proxy — any case where fetch rejects.

Common situations: Corporate proxies blocking api.coingecko.com, CI runners without internet access, DNS misconfiguration, transient CoinGecko connectivity incidents.

Related errors


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