jackwener/OpenCLI · error · CommandExecutionError
Failed to extract AIbase daily news: ${getErrorMessage(error
Error message
Failed to extract AIbase daily news: ${getErrorMessage(error)} What it means
loadAibaseNews catches any rejection from page.evaluate(buildExtractAibaseNewsJs()) and rethrows it as a CommandExecutionError 'Failed to extract AIbase daily news: <message>'. This wraps in-page script failures (exceptions thrown inside the browser context) or evaluation infrastructure errors, distinct from payload-shape and selector-drift checks done later in toRows.
Source
Thrown at clis/aibase/news.js:86
}
const rows = (Array.isArray(payload.rows) ? payload.rows : [])
.map((row, index) => ({
rank: index + 1,
title: normalizeText(row.title),
url: normalizeText(row.url),
}))
.filter((row) => row.title && row.url);
if (rows.length === 0) {
throw new EmptyResultError('aibase news', 'AIbase daily page loaded, but no article rows with title and URL were extracted.');
}
return rows.slice(0, limit).map((row, index) => ({ ...row, rank: index + 1 }));
}
async function loadAibaseNews(page, args) {
const limit = normalizeLimit(args.limit);
await page.goto(AIBASE_DAILY_URL, { waitUntil: 'load', settleMs: 3000 });
const payload = await page.evaluate(buildExtractAibaseNewsJs()).catch((error) => {
throw new CommandExecutionError(`Failed to extract AIbase daily news: ${getErrorMessage(error)}`);
});
return toRows(payload, limit);
}
export const aibaseNewsCommand = cli({
site: 'aibase',
name: 'news',
access: 'read',
description: 'AIbase 日报 - 每天三分钟关注AI行业趋势',
domain: 'www.aibase.com',
strategy: Strategy.PUBLIC,
browser: true,
args: [
{ name: 'limit', type: 'int', default: DEFAULT_LIMIT, help: `Number of news items to return (max ${MAX_LIMIT})` },
],
columns: ['rank', 'title', 'url'],
func: loadAibaseNews,
});View on GitHub (pinned to 49907e53dc)
Solutions
- Read the wrapped message after the colon — it names the underlying in-page error.
- Re-run the command; execution-context-destroyed errors are usually transient navigation races.
- Harden the extraction script: wrap new URL(anchor.getAttribute('href'), location.href) in try/catch and skip bad hrefs.
- Increase settle time before evaluate or switch to foreground mode; refresh the browser session if the browser is in a bad state.
Example fix
// before
const url = new URL(anchor.getAttribute('href'), location.href).href;
// after
let url = '';
try { url = new URL(anchor.getAttribute('href'), location.href).href; } catch { return; } Defensive patterns
Strategy: retry
Try / catch
try {
await runCommand(['aibase', 'news']);
} catch (e) {
if (e instanceof CommandExecutionError && e.message.startsWith('Failed to extract AIbase daily news:')) {
const cause = e.message.slice('Failed to extract AIbase daily news:'.length).trim();
console.error(`In-page extraction failed (${cause}); retrying`);
} else throw e;
} Prevention
- Harden injected scripts with try/catch around URL parsing and DOM access
- Increase settle time before evaluate on slow pages
- Retry on execution-context-destroyed errors caused by SPA navigations
- Keep the browser session and browser binary healthy/up to date
When it happens
Trigger: The extraction IIFE throws in page context (e.g. new URL(...) on a malformed href throws SyntaxError, or document access fails), or page.evaluate itself rejects (execution context destroyed by navigation, browser closed, evaluate timed out).
Common situations: Site emits anchors with malformed hrefs (invalid URL syntax) crashing new URL(); SPA navigations destroying the execution context mid-run; headless browser crashed on the heavy page; browser version incompatibilities with the evaluate API.
Related errors
- ${label} failed: ${error?.message ?? error}
- ${label} returned an unexpected payload shape; expected an a
- ${config.site} login
- AIbase daily page returned an unreadable payload
- AIbase daily selector drift: ${reason}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/17b5d67803f49548.
Report an issue: GitHub.