jackwener/OpenCLI · error · CommandExecutionError
coingecko trending request failed: ${error?.message || error
Error message
coingecko trending request failed: ${error?.message || error} What it means
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.
Source
Thrown at clis/coingecko/trending.js:24
} from '@jackwener/opencli/errors';
cli({
site: 'coingecko',
name: 'trending',
access: 'read',
description: 'Top trending cryptocurrencies on CoinGecko in the last 24h (search-volume based).',
domain: 'api.coingecko.com',
strategy: Strategy.PUBLIC,
browser: false,
args: [],
columns: ['rank', 'id', 'symbol', 'name', 'marketCapRank', 'priceBtc', 'thumb'],
func: async () => {
const url = 'https://api.coingecko.com/api/v3/search/trending';
let resp;
try {
resp = await fetch(url, { headers: { 'User-Agent': 'Mozilla/5.0' } });
} catch (error) {
throw new CommandExecutionError(`coingecko trending request failed: ${error?.message || error}`);
}
if (resp.status === 429) {
throw new CommandExecutionError('coingecko returned HTTP 429 (rate limited)', 'Wait and retry.');
}
if (!resp.ok) {
throw new CommandExecutionError(`coingecko trending failed: HTTP ${resp.status}`);
}
let data;
try {
data = await resp.json();
} catch (error) {
throw new CommandExecutionError(`coingecko returned malformed JSON: ${error?.message || error}`);
}
const coins = Array.isArray(data?.coins) ? data.coins : [];
if (coins.length === 0) {
throw new EmptyResultError('coingecko trending', 'coingecko returned no trending coins.');
}
return coins.map((entry, i) => {View on GitHub (pinned to 49907e53dc)
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
Example fix
// before (Node 16) $ coingecko trending // TypeError: fetch is not a function -> wrapped in this error // after $ nvm use 18 && coingecko trending
Defensive patterns
Strategy: retry
Validate before calling
const hasFetch = typeof globalThis.fetch === 'function';
if (!hasFetch) throw new Error('Node >= 18 required for global fetch');
await fetch('https://api.coingecko.com/api/v3/ping', { method: 'HEAD' }); // connectivity precheck Type guard
function isFetchNetworkError(e) {
return e instanceof TypeError || /fetch failed|ENOTFOUND|ECONNREFUSED|ECONNRESET|ETIMEDOUT/.test(String(e?.cause?.code || e?.message));
} Try / catch
try {
await runCli('coingecko trending');
} catch (e) {
if (/trending request failed/.test(e.message)) {
// network layer: check connectivity/proxy, then retry with backoff
await new Promise(r => setTimeout(r, 5000));
await runCli('coingecko trending');
} else throw e;
} Prevention
- 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
When it happens
Trigger: 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}`.
Common situations: 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).
Related errors
- archive search request failed: ${error?.message || error}
- archive wayback request failed: ${error?.message || error}
- Failed to fetch Chess.com API ${url}: ${error?.message || er
- coingecko categories request failed: ${err?.message ?? err}
- FETCH_ERROR
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/d7ea96acbfbfe6c7.
Report an issue: GitHub.