{"record":{"id":"93434a1ada46529f","repo":"jackwener/OpenCLI","slug":"coingecko-top-request-failed-error-message","errorCode":null,"errorMessage":"coingecko top request failed: ${error?.message || error}","messagePattern":"coingecko top request failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/coingecko/top.js","lineNumber":39,"sourceCode":"    if (!Number.isInteger(limit) || limit <= 0) {\n      throw new ArgumentError('limit must be a positive integer');\n    }\n    if (limit > 250) {\n      throw new ArgumentError('limit must be <= 250 (CoinGecko per_page upper bound)');\n    }\n\n    const url = new URL('https://api.coingecko.com/api/v3/coins/markets');\n    url.searchParams.set('vs_currency', currency);\n    url.searchParams.set('order', 'market_cap_desc');\n    url.searchParams.set('per_page', String(limit));\n    url.searchParams.set('page', '1');\n    url.searchParams.set('sparkline', 'false');\n\n    let resp;\n    try {\n      resp = await fetch(url, { headers: { 'User-Agent': 'Mozilla/5.0' } });\n    } catch (error) {\n      throw new CommandExecutionError(`coingecko top request failed: ${error?.message || error}`);\n    }\n    if (!resp.ok) throw new CommandExecutionError(`coingecko top failed: HTTP ${resp.status}`);\n    let data;\n    try {\n      data = await resp.json();\n    } catch (error) {\n      throw new CommandExecutionError(`coingecko returned malformed JSON: ${error?.message || error}`);\n    }\n    if (data?.error) throw new CommandExecutionError(`coingecko returned error: ${data.error}`);\n    if (!Array.isArray(data)) throw new CommandExecutionError('coingecko returned an unexpected response');\n    if (data.length === 0) throw new EmptyResultError('coingecko top', 'coingecko returned no market data');\n\n    return data.map((c) => ({\n      rank: c.market_cap_rank,\n      symbol: String(c.symbol ?? '').toUpperCase(),\n      name: c.name,\n      price: c.current_price,\n      change24hPct: c.price_change_percentage_24h,","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/coingecko/top.js#L21-L57","documentation":"This CommandExecutionError is thrown when the fetch() call itself rejects — the request never completed, so there is no HTTP status. The library wraps the network error and rethrows with the original message. Typical root causes are DNS failures, connection refused/reset, TLS errors, or timeouts.","triggerScenarios":"api.coingecko.com unreachable: DNS resolution failure, no internet/VPN blocking, TLS handshake failure, request timeout/abort, connection reset by a firewall or GFW-style block.","commonSituations":"Offline laptop or dead Wi-Fi; corporate firewall blocking crypto-related domains; IPv6 misconfiguration; DNS hijacking; CoinGecko regional blocks requiring a proxy/VPN.","solutions":["Check basic connectivity (curl https://api.coingecko.com/api/v3/ping) and retry.","Fix DNS/network issues: try a different DNS server (1.1.1.1) or network.","If the domain is blocked in your region/network, use a VPN or HTTPS proxy (HTTPS_PROXY env var).","Configure a longer timeout or retry with exponential backoff for transient outages.","Verify system clock and CA certificates if the message indicates a TLS error."],"exampleFix":"// before\nconst rows = await runCli('coingecko', 'top');\n// after\nconst rows = await retry(async () => runCli('coingecko', 'top'), { retries: 3, factor: 2 });","handlingStrategy":"retry","validationCode":"const reachable = await fetch('https://api.coingecko.com/api/v3/ping', { signal: AbortSignal.timeout(5000) })\n  .then(r => r.ok).catch(() => false);\nif (!reachable) throw new Error('api.coingecko.com is unreachable from this network');","typeGuard":"null","tryCatchPattern":"async function withRetry(fn, attempts = 3) {\n  for (let i = 0; ; i++) {\n    try { return await fn(); }\n    catch (e) {\n      if (i >= attempts - 1 || !/request failed|ECONN|ENOTFOUND|timeout/i.test(e.message)) throw e;\n      await new Promise(r => setTimeout(r, 2 ** i * 1000));\n    }\n  }\n}\nconst rows = await withRetry(() => runCli('coingecko', 'top'));","preventionTips":["Set HTTPS_PROXY/VPN if the domain is blocked in your region","Configure reasonable timeouts and exponential backoff","Check DNS/VPN before long batch jobs","Monitor https://status.coingecko.com for outages"],"tags":["network","dns","connection","timeout"],"backgroundTag":"connection-refused","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}