jackwener/OpenCLI · error · CommandExecutionError

Failed to load Booking.com search page: ${err?.message || er

Error message

Failed to load Booking.com search page: ${err?.message || err}

What it means

This CommandExecutionError wraps any failure of page.goto(url) while navigating the automated browser to the constructed Booking.com search URL. The library throws it so the underlying navigation error (timeout, DNS failure, aborted request) is reported with clear context naming the page that failed to load. The original error's message is embedded via err?.message || err.

Source

Thrown at clis/booking/search.js:260

    const checkin = normalizeDate(kwargs.checkin, 'checkin');
    const checkout = normalizeDate(kwargs.checkout, 'checkout');
    if (checkin >= checkout) {
      throw new ArgumentError(`checkout (${checkout}) must be after checkin (${checkin})`);
    }
    const adults = normalizePositiveInt(kwargs.adults, 2, 'adults', 30);
    const rooms = normalizePositiveInt(kwargs.rooms, 1, 'rooms', 30);
    const children = normalizeNonNegativeInt(kwargs.children, 0, 'children', 10);
    const currency = normalizeCurrency(kwargs.currency);
    const lang = normalizeLang(kwargs.lang);
    const limit = normalizePositiveInt(kwargs.limit, 25, 'limit', 100);
    const offset = normalizeNonNegativeInt(kwargs.offset, 0, 'offset', 1000);

    const url = buildSearchUrl({ destination, checkin, checkout, adults, rooms, children, offset, currency, lang });

    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;

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Check network connectivity and that https://www.booking.com is reachable from the environment.
  2. Retry the command — transient timeouts are common; increase the navigation timeout if available.
  3. Verify the destination parameter is a sane, non-empty, URL-encodable string.
  4. If behind a proxy/firewall, configure the browser/environment proxy settings or whitelist booking.com.
  5. Inspect the embedded err message to distinguish timeout vs DNS vs aborted navigation.

Example fix

// before (flaky network, one attempt)
await page.goto(url);
// after (retry with backoff)
for (let i = 0; i < 3; i++) {
  try { await page.goto(url); break; } catch (e) { await new Promise(r => setTimeout(r, 1000 * (i + 1))); if (i === 2) throw e; }
}
Defensive patterns

Strategy: retry

Validate before calling

const reachable = await fetch('https://www.booking.com', { method: 'HEAD' }).then(r => r.ok).catch(() => false);
if (!reachable) throw new Error('booking.com is not reachable from this environment');

Try / catch

try {
  await booking.search(params);
} catch (e) {
  if (/Failed to load Booking.com search page/.test(e.message)) {
    // inspect embedded cause: e.message includes err?.message
    await new Promise(r => setTimeout(r, 3000));
    return booking.search(params); // one retry for transient navigation failures
  }
  throw e;
}

Prevention

When it happens

Trigger: page.goto(url) throws or rejects: network outage, DNS failure, Booking.com unreachable, navigation timeout, browser/page crashed, or an invalid URL produced by buildSearchUrl (e.g. malformed destination encoding).

Common situations: Running in a sandboxed/CI environment with no internet access; corporate proxy blocking booking.com; slow connection exceeding the default navigation timeout; headless browser detected and connection reset; destination string containing characters that break the URL.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/f8e08bcde37f7f06. Report an issue: GitHub.