jackwener/OpenCLI · error · CommandExecutionError
Failed to open Zhihu answer ${answerId}: ${err instanceof Er
Error message
Failed to open Zhihu answer ${answerId}: ${err instanceof Error ? err.message : String(err)} What it means
After argument validation the command navigates Chrome (via the page controller) to https://www.zhihu.com/answer/<answerId>. If page.goto throws (navigation failure, timeout, connection error), the error is wrapped in a CommandExecutionError that includes the answer id and the underlying message, with a hint to open the URL in Chrome and retry.
Source
Thrown at clis/zhihu/answer-comments.js:60
}
const topLevelLimit = Number(kwargs.limit ?? 20);
if (!Number.isInteger(topLevelLimit) || topLevelLimit <= 0 || topLevelLimit > MAX_LIMIT) {
throw new ArgumentError(`--limit must be a positive integer no greater than ${MAX_LIMIT}`);
}
const repliesLimit = Number(kwargs['replies-limit'] ?? 3);
if (!Number.isInteger(repliesLimit) || repliesLimit < 0 || repliesLimit > MAX_REPLIES_LIMIT) {
throw new ArgumentError(`--replies-limit must be an integer between 0 and ${MAX_REPLIES_LIMIT}`);
}
const order = String(kwargs.order ?? 'score');
if (order !== 'score' && order !== 'latest') {
throw new ArgumentError('--order must be score or latest');
}
const { answerId } = target;
try {
await page.goto(`https://www.zhihu.com/answer/${answerId}`);
} catch (err) {
throw new CommandExecutionError(
`Failed to open Zhihu answer ${answerId}: ${err instanceof Error ? err.message : String(err)}`,
'Open the answer URL in Chrome and retry after the page is reachable.',
);
}
const currentQuestionId = page.getCurrentUrl
? extractQuestionIdFromAnswerUrl(await page.getCurrentUrl().catch(() => ''))
: '';
const questionId = target.questionId || currentQuestionId;
const roots = await fetchRootComments(page, answerId, order, topLevelLimit);
if (roots.length === 0) {
throw new EmptyResultError('zhihu answer-comments', `No comments found for answer ${answerId}.`);
}
const repliesByRoot = await fetchRepliesByRoot(page, roots, repliesLimit);
return buildCommentRows(roots, repliesByRoot, { answerId, questionId });
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Open the answer URL in Chrome manually, confirm it loads and you are logged in, then retry the command
- Check network/VPN/proxy connectivity to zhihu.com
- Verify the answer id is valid and the answer is not deleted (test the URL in a browser)
- Increase navigation timeout or retry after a delay
Example fix
// before
await page.goto(`https://www.zhihu.com/answer/${answerId}`);
// after
try {
await page.goto(`https://www.zhihu.com/answer/${answerId}`);
} catch (err) {
await sleep(2000);
await page.goto(`https://www.zhihu.com/answer/${answerId}`);
} Defensive patterns
Strategy: try-catch
Validate before calling
// optional pre-check
const reachable = await fetch('https://www.zhihu.com', { method: 'HEAD' }).then(r => r.ok).catch(() => false);
if (!reachable) throw new Error('zhihu.com unreachable; check network/VPN'); Try / catch
try { rows = await answerComments(id); }
catch (err) {
if (err instanceof CommandExecutionError && /Failed to open Zhihu answer/.test(err.message)) {
await retryWithBackoff(() => answerComments(id), 3);
} else throw err;
} Prevention
- Ensure Chrome is running, logged into Zhihu, and can load the answer manually
- Check proxy/VPN settings that could block zhihu.com
- Add bounded retries with backoff around navigation-dependent commands
- Validate the answer id exists before automating
When it happens
Trigger: Network outage or DNS failure; Zhihu returning a hard error/anti-bot block that aborts navigation; page.goto timeout on a slow connection; invalid answer id causing a protocol-level navigation error.
Common situations: Corporate proxy or VPN blocking zhihu.com; Chrome not logged in and Zhihu throttling; transient Wi-Fi drops during automation runs; deleted answers leading to abortive redirects.
Related errors
- Failed to load Booking.com search page: ${err?.message || er
- Failed to open Chess.com analysis board: ${error?.message ||
- coupang search filtered navigation failed: ${error?.message
- Failed to open Youdao Note URL: ${error instanceof Error ? e
- Failed to open Zhihu answer ${answerId}: ${err instanceof Er
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/4a53aac70e1c0ca5.
Report an issue: GitHub.