jackwener/OpenCLI · error · CommandExecutionError
Youdao note extractor failed: ${error instanceof Error ? err
Error message
Youdao note extractor failed: ${error instanceof Error ? error.message : String(error)} What it means
page.evaluate(buildExtractorJs()) executes the injected extractor script in the page; any exception it throws (or a broken evaluate bridge) is rethrown as 'Youdao note extractor failed: <msg>'. The wrapper preserves the underlying error message from the browser context.
Source
Thrown at clis/youdao/note.js:246
columns: ['title', 'content', 'summary', 'keywords', 'created_at', 'file_size', 'url'],
func: async function(page, kwargs) {
const url = normalizeShareUrl(kwargs.url);
try {
await page.goto(url);
} catch (error) {
throw new CommandExecutionError(`Failed to open Youdao Note URL: ${error instanceof Error ? error.message : String(error)}`);
}
try {
await page.wait({ selector: '#root, .file-name, body', timeout: 10 });
} catch {
await page.wait(3).catch(function() {});
}
await page.wait(2).catch(function() {});
let payload;
try {
payload = await page.evaluate(buildExtractorJs());
} catch (error) {
throw new CommandExecutionError(`Youdao note extractor failed: ${error instanceof Error ? error.message : String(error)}`);
}
return [normalizeExtractionResult(payload, url)];
},
});
export var __test__ = {
buildExtractorJs: buildExtractorJs,
command: command,
formatYoudaoTimestamp: formatYoudaoTimestamp,
normalizeExtractionResult: normalizeExtractionResult,
normalizeShareUrl: normalizeShareUrl,
};
View on GitHub (pinned to 49907e53dc)
Solutions
- Read the wrapped cause message to see what failed inside the page
- Re-run after the page settles; ensure no concurrent navigation occurs during evaluate
- Update buildExtractorJs for the current Youdao DOM/store layout
- Add defensive null checks inside the extractor script for every store/DOM lookup
Example fix
// before const store = window.__INITIAL_STATE__.note; // after const store = (window.__INITIAL_STATE__ && window.__INITIAL_STATE__.note) || null; if (!store) return null; // normalization will report the missing fields
Defensive patterns
Strategy: try-catch
Type guard
function isExtractionFailure(e) {
return e instanceof Error && /^Youdao note extractor failed: /.test(e.message);
} Try / catch
try {
await cli.youdao.note({ url });
} catch (e) {
if (/Youdao note extractor failed: (.+)/.test(e.message)) {
const cause = e.message.match(/Youdao note extractor failed: (.+)/)[1];
console.error('In-page extractor error:', cause);
} else throw e;
} Prevention
- Keep buildExtractorJs defensive (null-check every store/DOM access)
- Avoid navigating the page during evaluate
- Pin/monitor Youdao frontend changes; smoke-test the extractor regularly
- Return null from the extractor instead of throwing for missing data
When it happens
Trigger: The injected script throws inside the page: expected store object absent, null dereference on missing DOM nodes, JSON serialization issues, or page context destroyed by navigation/redirect mid-evaluate.
Common situations: Youdao page changed structure after a site update; evaluate ran before SPA mount; page navigated away during extraction (login redirect); very large payload breaking the evaluate bridge.
Related errors
- ${label}: ${String(payload.error)}
- ${label} returned malformed extraction payload
- LinkedIn whoami failed: ${result.detail}
- Youdao note parser did not extract a title
- Unexpected 12306 probe: ${JSON.stringify(probe)}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/2f5d806703e9c1ce.
Report an issue: GitHub.