jackwener/OpenCLI · error · CommandExecutionError
Failed to fetch Douyin comments for video ${awemeId}: ${erro
Error message
Failed to fetch Douyin comments for video ${awemeId}: ${error instanceof Error ? error.message : String(error)} What it means
A CommandExecutionError wrapping any non-CliError failure raised while fetching top comments for a video during douyin user-videos. fetchTopComments rethrows CliError subclasses untouched, but converts unexpected exceptions (browser page errors, API failures, timeouts) into a single message prefixed with the awemeId so batch processing can surface which video failed.
Source
Thrown at clis/douyin/user-videos.js:53
return Math.min(DEFAULT_COMMENT_LIMIT, Math.max(1, Math.round(numeric)));
}
async function mapInBatches(items, concurrency, mapper) {
const results = [];
for (let index = 0; index < items.length; index += concurrency) {
const chunk = items.slice(index, index + concurrency);
results.push(...(await Promise.all(chunk.map(mapper))));
}
return results;
}
async function fetchTopComments(page, awemeId, count) {
try {
return await fetchDouyinComments(page, awemeId, count);
}
catch (error) {
if (error instanceof CliError) {
throw error;
}
throw new CommandExecutionError(`Failed to fetch Douyin comments for video ${awemeId}: ${error instanceof Error ? error.message : String(error)}`);
}
}
cli({
site: 'douyin',
name: 'user-videos',
access: 'read',
description: '获取指定用户的视频列表(含下载地址和热门评论)',
domain: 'www.douyin.com',
strategy: Strategy.COOKIE,
args: [
{ name: 'sec_uid', type: 'string', required: true, positional: true, help: '用户 sec_uid(个人主页 URL 末尾部分,也可直接传整条主页 URL)' },
{ name: 'limit', type: 'int', default: 20, help: '获取数量(最大 20)' },
{ name: 'with_comments', type: 'bool', default: true, help: '包含热门评论(默认: true)' },
{ name: 'comment_limit', type: 'int', default: 10, help: '每个视频获取多少条评论(最大 10)' },
],
columns: ['index', 'aweme_id', 'title', 'duration', 'digg_count', 'play_url', 'top_comments'],
func: async (page, kwargs) => {
const secUid = normalizeSecUid(kwargs.sec_uid);View on GitHub (pinned to 49907e53dc)
Solutions
- Read the wrapped error.message (appended after the awemeId) to find the underlying cause.
- Re-run the command with --with-comments disabled (or --comment-limit lowered) to confirm the videos themselves still list fine.
- Reduce --comment-limit / concurrency pressure and retry after a pause if rate limited.
- Refresh the Douyin session (re-run auth) if the underlying message suggests auth or empty responses.
- If persistent, update the CLI package — the comment fetcher may lag a Douyin DOM change.
Defensive patterns
Strategy: try-catch
Try / catch
try {
const { videos } = await run('douyin user-videos', { sec_uid, with_comments: true });
} catch (e) {
if (e.name === 'CommandExecutionError' && /comments for video/.test(e.message)) {
console.warn(`comment fetch failed (${e.message}); retrying without comments`);
return run('douyin user-videos', { sec_uid, with_comments: false });
}
throw e;
} Prevention
- Lower --comment-limit to reduce per-video work and rate-limit pressure.
- Keep the Douyin session valid; refresh auth if failures cluster.
- Prefer with_comments: false for bulk runs; fetch comments selectively.
When it happens
Trigger: Calling `douyin user-videos --with-comments` when fetchDouyinComments throws a non-CliError for one of the video's awemeIds — e.g. the comment popup never loads, the page DOM changed, or the browser tab crashed mid-batch.
Common situations: Douyin DOM/API change breaking the comment scraper; rate limiting or a network hiccup while mapInBatches hits videos concurrently; expired login state causing comment requests to return error pages instead of data.
Related errors
- 1point3acres request failed: ${error?.message || error}
- 1point3acres request failed: HTTP ${res.status} ${res.status
- Barchart greeks request failed: HTTP ${data.status}${data.st
- dianping could not resolve cityId for '${cityArg}' (pinyin=$
- Douyin API request failed (${method} ${url}): ${error instan
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/901d1644bd0c3877.
Report an issue: GitHub.