jackwener/OpenCLI · error · CommandExecutionError
autohome ${contextHint} network error: ${err?.message || err
Error message
autohome ${contextHint} network error: ${err?.message || err} What it means
ahFetch() wraps any network-level failure from its HTTP client into this CommandExecutionError, prefixing the request context (contextHint) and the underlying error message. It signals the autohome page could not be retrieved at the transport layer (before any HTTP status was read).
Source
Thrown at clis/autohome/utils.js:137
if (!value || typeof value !== 'object' || Array.isArray(value)) {
throw new CommandExecutionError(`${label} returned an unexpected payload shape; expected an object.`);
}
return value;
}
/** Fetch an Autohome page as text. The grade + koubei pages are UTF-8. */
export async function ahFetch(url, contextHint) {
let resp;
try {
resp = await fetch(url, {
headers: {
'User-Agent': UA,
Referer: `${AH_BASE}/`,
'Accept-Language': 'zh-CN,zh;q=0.9',
},
});
} catch (err) {
throw new CommandExecutionError(`autohome ${contextHint} network error: ${err?.message || err}`);
}
if (!resp.ok) {
throw new CommandExecutionError(`autohome ${contextHint} HTTP ${resp.status}`);
}
return resp.text();
}
/** Extract __NEXT_DATA__ pageProps from a koubei page (pure, testable). */
export function extractPageProps(html) {
const m = String(html || '').match(/<script id="__NEXT_DATA__"[^>]*>([\s\S]*?)<\/script>/);
if (!m) return null;
try {
const data = JSON.parse(m[1]);
return (data && data.props && data.props.pageProps) || null;
} catch {
return null;
}
}View on GitHub (pinned to 49907e53dc)
Solutions
- Check basic connectivity (curl https://k.autohome.com.cn) and DNS
- Retry with backoff — many failures are transient
- Check proxy/firewall/VPN settings that may block autohome.com.cn domains
Example fix
// before const html = await ahFetch(url, 'koubei'); // after const html = await withRetry(3, () => ahFetch(url, 'koubei'));
Defensive patterns
Strategy: retry
Validate before calling
// pre-check connectivity
const online = await fetch('https://k.autohome.com.cn/', { method: 'HEAD' })
.then(() => true).catch(() => false);
if (!online) throw new Error('No connectivity to autohome'); Try / catch
try {
const html = await ahFetch(url, 'koubei');
} catch (err) {
if (err instanceof CommandExecutionError && /network error/.test(err.message)) {
await sleep(backoff(attempt++));
return fetchWithRetry(url, attempt);
}
throw err;
} Prevention
- Implement retry with exponential backoff for all autohome fetches
- Check proxy/firewall settings if running in corporate/container environments
- Fail fast with a connectivity check when offline
When it happens
Trigger: DNS resolution failure, connection timeout/reset, TLS error, or proxy unreachability while fetching an autohome grade/koubei page.
Common situations: No internet or captive portal; corporate firewall/Great-Firewall blocking autohome domains; transient network flakiness; IPv6/DNS misconfiguration.
Related errors
- 12306 queryByTrainNo returned HTTP ${resp.status}
- 12306 queryByTrainNo returned non-JSON body
- 12306 ${endpoint} returned non-JSON body
- 1point3acres request failed: HTTP ${res.status} ${res.status
- ${label} returned HTTP ${resp.status}: ${summarizeApiError(p
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/f38845ba58a6abfc.
Report an issue: GitHub.