{"record":{"id":"d7ea96acbfbfe6c7","repo":"jackwener/OpenCLI","slug":"coingecko-trending-request-failed-error-messag","errorCode":null,"errorMessage":"coingecko trending request failed: ${error?.message || error}","messagePattern":"coingecko trending request failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/coingecko/trending.js","lineNumber":24,"sourceCode":"} from '@jackwener/opencli/errors';\n\ncli({\n    site: 'coingecko',\n    name: 'trending',\n    access: 'read',\n    description: 'Top trending cryptocurrencies on CoinGecko in the last 24h (search-volume based).',\n    domain: 'api.coingecko.com',\n    strategy: Strategy.PUBLIC,\n    browser: false,\n    args: [],\n    columns: ['rank', 'id', 'symbol', 'name', 'marketCapRank', 'priceBtc', 'thumb'],\n    func: async () => {\n        const url = 'https://api.coingecko.com/api/v3/search/trending';\n        let resp;\n        try {\n            resp = await fetch(url, { headers: { 'User-Agent': 'Mozilla/5.0' } });\n        } catch (error) {\n            throw new CommandExecutionError(`coingecko trending request failed: ${error?.message || error}`);\n        }\n        if (resp.status === 429) {\n            throw new CommandExecutionError('coingecko returned HTTP 429 (rate limited)', 'Wait and retry.');\n        }\n        if (!resp.ok) {\n            throw new CommandExecutionError(`coingecko trending failed: HTTP ${resp.status}`);\n        }\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        const coins = Array.isArray(data?.coins) ? data.coins : [];\n        if (coins.length === 0) {\n            throw new EmptyResultError('coingecko trending', 'coingecko returned no trending coins.');\n        }\n        return coins.map((entry, i) => {","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/coingecko/trending.js#L6-L42","documentation":"This CommandExecutionError wraps any low-level fetch() rejection while calling the CoinGecko trending endpoint (https://api.coingecko.com/api/v3/search/trending). The fetch itself threw — meaning no HTTP response was received at all — so the library surfaces the underlying error message (DNS failure, connection reset, TLS error, abort, etc.) prefixed with context. It indicates a network-layer problem, not an API-level HTTP error status.","triggerScenarios":"The `await fetch(url, { headers: { 'User-Agent': 'Mozilla/5.0' } })` call in the trending command rejects: no internet connectivity, DNS resolution failure for api.coingecko.com, connection refused/timeout, TLS interception, or a Node version without global fetch (<18). The catch block immediately rethrows as CommandExecutionError with `${error?.message || error}`.","commonSituations":"Running the CLI offline or behind a corporate proxy/firewall that blocks api.coingecko.com, DNS misconfiguration, VPN dropping mid-command, or running on Node < 18 where fetch is undefined (TypeError: fetch is not a function).","solutions":["Check basic connectivity: curl -I https://api.coingecko.com/api/v3/search/trending","If behind a proxy, configure HTTPS_PROXY / NODE_EXTRA_CA_CERTS so Node's fetch can reach the host","Upgrade to Node >= 18 where global fetch exists (TypeError 'fetch is not a function' means missing fetch)","Retry after checking status.coingecko.com in case of an outage"],"exampleFix":"// before (Node 16)\n$ coingecko trending  // TypeError: fetch is not a function -> wrapped in this error\n// after\n$ nvm use 18 && coingecko trending","handlingStrategy":"retry","validationCode":"const hasFetch = typeof globalThis.fetch === 'function';\nif (!hasFetch) throw new Error('Node >= 18 required for global fetch');\nawait fetch('https://api.coingecko.com/api/v3/ping', { method: 'HEAD' }); // connectivity precheck","typeGuard":"function isFetchNetworkError(e) {\n  return e instanceof TypeError || /fetch failed|ENOTFOUND|ECONNREFUSED|ECONNRESET|ETIMEDOUT/.test(String(e?.cause?.code || e?.message));\n}","tryCatchPattern":"try {\n  await runCli('coingecko trending');\n} catch (e) {\n  if (/trending request failed/.test(e.message)) {\n    // network layer: check connectivity/proxy, then retry with backoff\n    await new Promise(r => setTimeout(r, 5000));\n    await runCli('coingecko trending');\n  } else throw e;\n}","preventionTips":["Run on Node >= 18 so global fetch exists","Configure HTTPS_PROXY/CA certs in corporate environments","Check connectivity or status.coingecko.com before scheduled runs","Add exponential backoff for network-layer failures"],"tags":["network","fetch","dns","coingecko","cli"],"backgroundTag":"fetch-network-error","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}