jackwener/OpenCLI · warning · EmptyResultError

No round-trip flights for ${fromCode} to ${toCode} on ${depa

Error message

No round-trip flights for ${fromCode} to ${toCode} on ${depart} .. ${ret}

What it means

This EmptyResultError from clis/trip/flight-round.js is thrown after the Trip.com round-trip flight page was successfully scraped but the DOM extraction returned zero rows. The command ran correctly end-to-end; the site simply had no matching round-trip flights for the given origin/destination and date pair. It is a structured 'no results' signal, not a scraping or auth failure, so callers can treat it as a normal empty result.

Source

Thrown at clis/trip/flight-round.js:76

        const searchUrl = buildFlightRoundSearchUrl(fromCode, toCode, depart, ret);
        await page.goto(searchUrl);
        const waitResult = await page.evaluate(WAIT_FOR_FLIGHTS_JS);
        if (waitResult === 'captcha') {
            throw new AuthRequiredError('trip.com', 'Trip.com is asking for a verification; complete it in your browser session and retry');
        }
        if (waitResult !== 'content') {
            throw new CommandExecutionError(`Trip.com flight page did not render flight cards (state=${String(waitResult)})`);
        }
        const raw = await page.evaluate(buildFlightExtractJs());
        if (!Array.isArray(raw)) {
            const reason = raw && typeof raw === 'object' && typeof raw.error === 'string'
                && /^malformed flight card \d+: [a-z /]+$/.test(raw.error)
                ? `: ${raw.error}`
                : '';
            throw new CommandExecutionError(`Trip.com flight DOM extraction returned malformed rows${reason}`);
        }
        if (raw.length === 0) {
            throw new EmptyResultError('trip flight-round', `No round-trip flights for ${fromCode} to ${toCode} on ${depart} .. ${ret}`);
        }
        return raw.slice(0, limit).map((r, i) => ({
            rank: i + 1,
            airline: r.airline,
            departureTime: r.departureTime,
            departureAirport: r.departureAirport,
            arrivalTime: r.arrivalTime,
            arrivalAirport: r.arrivalAirport,
            duration: r.duration,
            stops: r.stops,
            price: r.price,
            currency: r.currency,
            url: searchUrl,
        }));
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Verify the route actually has round-trip service on those dates by checking Trip.com in a browser with the same URL.
  2. Confirm --depart and --ret are future dates within Trip.com's booking window and correctly formatted (ISO).
  3. Adjust dates or route (nearby airports) and retry.
  4. Catch EmptyResultError in the caller and handle it as 'no flights' rather than a crash.

Example fix

// before
const rows = await runTripFlightRound({ from: 'XYZ', to: 'ABC', depart: '2020-01-01', ret: '2020-01-02' });
// after
try {
  const rows = await runTripFlightRound({ from: 'SFO', to: 'LAX', depart: '2026-09-10', ret: '2026-09-15' });
} catch (e) {
  if (e instanceof EmptyResultError) return [];
  throw e;
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (!/^[A-Z]{3}$/.test(from) || !/^[A-Z]{3}$/.test(to)) throw new Error('invalid IATA codes');
const dep = new Date(depart), ret = new Date(ret);
if (isNaN(dep) || isNaN(ret) || dep < new Date() || ret < dep) throw new Error('invalid round-trip dates');

Type guard

const isEmptyResult = (e) => e instanceof EmptyResultError || e?.name === 'EmptyResultError';

Try / catch

try {
  const flights = await runTripFlightRound(args);
} catch (e) {
  if (isEmptyResult(e)) return [];
  throw e;
}

Prevention

When it happens

Trigger: Running the flight-round command with --from/--to/--depart/--ret where Trip.com's search page renders zero flight cards, e.g. after page.evaluate(buildFlightExtractJs()) returns an empty array and raw.length === 0.

Common situations: Searching an obscure or seasonal route with no service on the chosen dates; requesting depart/ret dates in the past or beyond the booking window; dates formatted so the URL points at an unlikely day; a very short same-day round trip where Trip.com shows nothing; transient site-side empty renders on slow loads.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


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