jackwener/OpenCLI · error · CommandExecutionError
github-trending request failed: ${error?.message || error}
Error message
github-trending request failed: ${error?.message || error} What it means
The HTTP request that fetches the GitHub Trending page threw (network-level failure before a response status was available), so the command wraps it in a CommandExecutionError prefixed 'github-trending request failed:' with the underlying error message. This is distinct from the HTTP-status failure variant ('HTTP <status>') — here the request itself failed to complete.
Source
Thrown at clis/github-trending/repos.js:143
throw new ArgumentError('--limit must be <= 25 (GitHub Trending lists at most 25 repositories)');
}
const limit = n;
const language = String(args.language ?? '').trim();
const path = language ? `/trending/${encodeURIComponent(language)}` : '/trending';
const url = new URL(`https://github.com${path}`);
url.searchParams.set('since', since);
let resp;
try {
resp = await fetch(url, {
headers: {
'User-Agent': 'Mozilla/5.0 (compatible; opencli/github-trending)',
Accept: 'text/html',
},
});
} catch (error) {
throw new CommandExecutionError(`github-trending request failed: ${error?.message || error}`);
}
if (!resp.ok) {
throw new CommandExecutionError(`github-trending request failed: HTTP ${resp.status}`);
}
const html = await resp.text();
const rows = parseTrendingHtml(html, limit);
if (rows.length === 0) {
throw new EmptyResultError('github-trending', language
? `no trending repositories for language "${language}" (${since})`
: `no trending repositories (${since})`);
}
return rows.map((row, index) => ({
rank: index + 1,
repo: row.repo,
description: row.description,
language: row.language,View on GitHub (pinned to 49907e53dc)
Solutions
- Check network connectivity to github.com (curl https://github.com/trending)
- Configure proxy environment variables (HTTPS_PROXY/HTTP_PROXY) if behind a proxy
- Retry after a short wait — transient DNS/connection failures often resolve
- If TLS interception is the cause, trust the corporate CA or set NODE_EXTRA_CA_CERTS
Example fix
// before
const html = await fetchTrending();
// after: retry transient failures
let html;
for (let i = 0; i < 3 && !html; i++) {
try { html = await fetchTrending(); } catch (e) { await new Promise(r => setTimeout(r, 1000 * (i + 1))); }
} Defensive patterns
Strategy: retry
Validate before calling
const reachable = await fetch('https://github.com', { method: 'HEAD' }).then(r => r.ok).catch(() => false);
if (!reachable) throw new Error('github.com unreachable — check network/proxy'); Type guard
function isRequestFailure(e) { return e instanceof Error && e.message.startsWith('github-trending request failed'); } Try / catch
try {
await run(['opencli', 'github-trending', 'repos']);
} catch (e) {
if (/request failed/.test(e.message) && attempt < 3) return retryWithBackoff(attempt + 1);
throw e;
} Prevention
- Configure HTTPS_PROXY correctly in CI/corporate environments
- Add retry with backoff around the command for transient network failures
- Pre-check connectivity to github.com in scripts before scraping runs
When it happens
Trigger: fetch to https://github.com/trending... rejects — DNS resolution failure, connection refused/timeout, TLS errors, proxy misconfiguration, or the fetch call throwing for any reason inside the try block.
Common situations: No internet access or offline environment; corporate proxy/firewall blocking github.com; DNS issues in containers/CI; transient GitHub connectivity problems; TLS interception certificates not trusted by Node.
Related errors
- toutiao hot-board request failed: ${error?.message || error}
- 1point3acres request failed: ${error?.message || error}
- archive search request failed: ${error?.message || error}
- archive search returned malformed JSON: ${error?.message ||
- archive snapshots request failed: ${error?.message || error}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/3ba3c1b42e24d38d.
Report an issue: GitHub.