jackwener/OpenCLI · error · CommandExecutionError
Trip.com poiSearch fetch failed: ${err instanceof Error ? er
Error message
Trip.com poiSearch fetch failed: ${err instanceof Error ? err.message : String(err)} What it means
fetchPoiSearch wraps the underlying fetch() to the Trip.com poiSearch endpoint. If fetch itself throws — network unreachable, DNS failure, TLS error, connection reset, timeout — the error is re-thrown as CommandExecutionError prefixed with 'Trip.com poiSearch fetch failed:'. It is distinct from HTTP status errors, which are reported separately.
Source
Thrown at clis/trip/utils.js:842
* airport / place matches, so this needs no browser session. Returns the raw
* `results` array. Missing/non-array `results` means schema drift; an explicit
* empty array is the only valid empty-result shape.
*/
export async function fetchPoiSearch(keyword) {
let response;
try {
response = await fetch(POI_SEARCH_ENDPOINT, {
method: 'POST',
headers: { 'content-type': 'application/json', currency: 'USD' },
body: JSON.stringify({
key: keyword,
mode: '0',
tripType: 'RT',
Head: { Currency: 'USD', Locale: 'en-US', Source: 'ONLINE', Channel: 'EnglishSite', ClientID: 'opencli-trip' },
}),
});
} catch (err) {
throw new CommandExecutionError(`Trip.com poiSearch fetch failed: ${err instanceof Error ? err.message : String(err)}`);
}
if (!response.ok) {
throw new CommandExecutionError(`Trip.com poiSearch failed with status ${response.status}`);
}
let payload;
try {
payload = await response.json();
} catch (err) {
throw new CommandExecutionError(`Trip.com poiSearch returned invalid JSON: ${err instanceof Error ? err.message : String(err)}`);
}
if (!Array.isArray(payload?.results)) {
throw new CommandExecutionError('Trip.com poiSearch returned malformed payload: missing results array');
}
return payload.results;
}
/**
* Flatten POI results into a flat suggestion list: each top-level city keeps itsView on GitHub (pinned to 49907e53dc)
Solutions
- Check network connectivity and DNS for the Trip.com API host (curl -v the endpoint)
- Retry — the error is often transient; add backoff around the CLI invocation
- If behind a proxy, set HTTPS_PROXY and ensure the proxy CA is trusted (NODE_EXTRA_CA_CERTS)
- Read the inner err.message in the thrown text to identify the exact cause (ENOTFOUND, ECONNRESET, certificate, etc.)
Example fix
// before
await tripcli(['attractions-search','--query','Kyoto']) // offline laptop
// after
// connect/VPN first, then retry with backoff
await retry(() => tripcli(['attractions-search','--query','Kyoto']), {retries:3, backoff:1000}) Defensive patterns
Strategy: try-catch
Validate before calling
// pre-check connectivity before invoking
try { await fetch('https://www.trip.com', { method: 'HEAD' }); } catch (e) { throw new Error('network unavailable: ' + e.message); } Type guard
null
Try / catch
try {
const results = await searchAttractions(keyword);
} catch (e) {
if (/poiSearch fetch failed:/.test(e.message)) {
if (/ENOTFOUND|ECONNRESET|ETIMEDOUT/.test(e.message)) return retryWithBackoff(() => searchAttractions(keyword), 3);
if (/certificate|CERT/.test(e.message)) { process.env.NODE_EXTRA_CA_CERTS && console.error('check CA bundle'); }
}
throw e;
} Prevention
- Retry transient network errors with exponential backoff
- Set HTTPS_PROXY/NODE_EXTRA_CA_CERTS correctly on corporate networks
- Monitor connectivity before batch runs
- Read the appended inner error message to distinguish DNS vs TLS vs reset
When it happens
Trigger: Calling any command path that goes through results -> fetchPoiSearch while offline; DNS cannot resolve the Trip.com API host; a proxy/firewall blocks the request; Node lacks a trusted CA for the TLS handshake; transient connection reset mid-handshake.
Common situations: Corporate proxy intercepting HTTPS; VPN dropping mid-request; missing NODE_EXTRA_CA_CERTS on corporate networks; IPv6 misconfiguration; rate-limit-induced connection drops at the network layer.
Related errors
- Failed to fetch Chess.com callback ${url}: ${error?.message
- ${label} request failed: ${err?.message ?? err}. Check that
- ${label} request failed: ${err?.message ?? err}
- mdn search request failed: ${err?.message ?? err}
- network error fetching signed URL: ${e.message}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/9c9c4e573f40289a.
Report an issue: GitHub.