jackwener/OpenCLI · error · CommandExecutionError
Failed to extract Booking.com cards: ${err?.message || err}
Error message
Failed to extract Booking.com cards: ${err?.message || err} What it means
This CommandExecutionError wraps any failure of page.evaluate(EXTRACTOR), the in-page script that scrapes property-card data from the Booking.com results DOM. It signals that scraping could not even complete (script exception, page navigated away, context destroyed), as opposed to scraping succeeding but returning unusable data.
Source
Thrown at clis/booking/search.js:274
try {
await page.goto(url);
} catch (err) {
throw new CommandExecutionError(`Failed to load Booking.com search page: ${err?.message || err}`);
}
// Booking lazy-loads price cells; wait for at least the first card price to settle.
try {
await page.wait('selector', '[data-testid=property-card]', { timeoutMs: 20000 });
} catch (_) {
// selector wait is best-effort — extractor handles empty case explicitly
}
let raw;
try {
raw = await page.evaluate(EXTRACTOR);
} catch (err) {
throw new CommandExecutionError(`Failed to extract Booking.com cards: ${err?.message || err}`);
}
if (raw && typeof raw === 'object' && raw.data && raw.session) {
raw = raw.data;
}
if (!raw || typeof raw !== 'object') {
throw new CommandExecutionError('Booking.com page returned no extractable data');
}
if (raw.blocked) {
throw new CommandExecutionError('Booking.com served a verification / captcha page; retry later or change profile');
}
if (raw.ok !== true) {
throw new CommandExecutionError('Booking.com extractor returned an invalid status');
}
if (!Array.isArray(raw.items)) {
throw new CommandExecutionError('Booking.com extractor returned malformed items');
}View on GitHub (pinned to 49907e53dc)
Solutions
- Retry the command — transient navigation/context destruction is common.
- Check whether the page is being redirected to a captcha and use a fresh/different browser profile.
- Update the library if Booking.com changed its DOM (extractor may be out of date).
- Read the embedded err message to identify whether it is a context-destroyed, script exception, or crash.
- Increase stability: avoid concurrent navigations on the same page and give the page time to settle before extraction.
Example fix
// before
const raw = await page.evaluate(EXTRACTOR);
// after (guard against stale context with a re-navigation retry)
let raw;
try { raw = await page.evaluate(EXTRACTOR); }
catch (e) { await page.goto(url); raw = await page.evaluate(EXTRACTOR); } Defensive patterns
Strategy: retry
Validate before calling
// ensure the page is stable and on the results URL before evaluating
if (!page.url().includes('booking.com')) throw new Error('page is not on booking.com'); Try / catch
try {
await booking.search(params);
} catch (e) {
if (/Failed to extract Booking.com cards/.test(e.message) && /context|navigat|crash/i.test(e.message)) {
await sleep(2000);
return booking.search(params); // re-navigates and re-extracts
}
throw e;
} Prevention
- Avoid navigating the shared page concurrently while a search is running.
- Keep the browser/tab open for the duration of the call.
- Update the library when Booking.com changes its DOM so the extractor stays valid.
- Run headless jobs with adequate memory to avoid tab crashes.
- Check for redirects/captcha pages between wait and extraction steps.
When it happens
Trigger: page.evaluate(EXTRACTOR) throws: the in-page extractor raised an exception, the page navigated/closed mid-evaluation, the execution context was destroyed, or the browser tab crashed.
Common situations: Booking.com DOM changed so the extractor references undefined helpers; page reloaded or redirected (bot verification) between wait and evaluate; browser tab closed by user/timeout during a long run; Memory/CPU pressure crashing the tab in CI.
Related errors
- coupang search extraction failed: ${error?.message || error}
- xiaohongshu collection DOM extraction returned malformed row
- Failed to fetch Barchart greeks for ${symbol}
- Booking.com page returned no extractable data
- Booking.com extractor returned an invalid status
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/027f87b4ee187ca6.
Report an issue: GitHub.