jackwener/OpenCLI · error · CommandExecutionError
Failed to fetch Chess.com callback ${url}: ${error?.message
Error message
Failed to fetch Chess.com callback ${url}: ${error?.message || error} What it means
The chess game command fetches `${CALLBACK_BASE}/${kind}/game/${id}` from Chess.com's callback API; if the fetch call itself rejects (network layer failure, not an HTTP error status), the error is wrapped in this CommandExecutionError with the URL and original message.
Source
Thrown at clis/chess/game.js:93
strategy: Strategy.PUBLIC,
browser: false,
args: [
{ name: 'game-url', type: 'string', required: true, positional: true, help: 'Full game URL, e.g. https://www.chess.com/game/live/168842570216' },
],
columns: [
'kind', 'game_id', 'date',
'white', 'white_rating', 'black', 'black_rating',
'result', 'winner_color', 'termination',
'eco', 'time_control', 'rated', 'ply_count', 'url',
],
func: async (kwargs) => {
const { kind, id } = parseGameUrl(kwargs['game-url']);
const url = `${CALLBACK_BASE}/${kind}/game/${id}`;
let resp;
try {
resp = await fetch(url, { headers: { 'User-Agent': UA, accept: 'application/json' } });
} catch (error) {
throw new CommandExecutionError(`Failed to fetch Chess.com callback ${url}: ${error?.message || error}`);
}
if (!resp || typeof resp !== 'object') {
throw new CommandExecutionError(`Chess.com callback returned an invalid response object for ${url}`);
}
if (resp.status === 404) {
throw new EmptyResultError(`Chess.com has no ${kind} game with id ${id}`);
}
if (!resp.ok) {
throw new CommandExecutionError(`Chess.com callback returned HTTP ${resp.status} for ${url}`);
}
let payload;
try {
payload = await resp.json();
} catch (error) {
throw new CommandExecutionError(`Chess.com callback returned malformed JSON for ${url}: ${error?.message || error}`);
}
return [summarizeGame({ kind, id, payload })];
},View on GitHub (pinned to 49907e53dc)
Solutions
- Check network connectivity and DNS, then retry the command.
- Verify the callback URL is reachable (curl the same URL with the same User-Agent/accept headers).
- Add retry with backoff around the fetch for transient network errors.
- Confirm firewall/proxy rules allow HTTPS to chess.com from the running environment.
Example fix
// before
resp = await fetch(url, { headers: { 'User-Agent': UA, accept: 'application/json' } });
// after
try {
resp = await fetch(url, { headers: { 'User-Agent': UA, accept: 'application/json' } });
} catch (error) {
throw new CommandExecutionError(`Failed to fetch Chess.com callback ${url}: ${error?.message || error}`);
} Defensive patterns
Strategy: retry
Validate before calling
const url = `${CALLBACK_BASE}/${kind}/game/${id}`;
await fetch(url, { method: 'HEAD' }).catch(() => { throw new Error('Chess.com callback endpoint unreachable'); }); Type guard
null
Try / catch
try {
resp = await fetch(url, { headers: { 'User-Agent': UA, accept: 'application/json' } });
} catch (error) {
// retry with backoff for transient network errors
await sleep(1000);
resp = await fetch(url, { headers: { 'User-Agent': UA, accept: 'application/json' } });
} Prevention
- Implement retry with exponential backoff around fetch
- Check connectivity/DNS before batch runs
- Allowlist chess.com in proxies/firewalls for CI environments
When it happens
Trigger: fetch() throws — DNS resolution failure, connection refused/reset, TLS errors, request timeout, or offline machine — when calling the Chess.com callback endpoint for the given game kind/id.
Common situations: No internet/VPN required for chess.com; corporate firewall blocking the domain; transient DNS failures; Node without network permissions in sandboxed CI.
Related errors
- ${label} request failed: ${err?.message ?? err}. Check that
- ${label} request failed: ${err?.message ?? err}
- mdn search request failed: ${err?.message ?? err}
- network error fetching signed URL: ${e.message}
- Trip.com poiSearch fetch failed: ${err instanceof Error ? er
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/21eaaf372c380a68.
Report an issue: GitHub.