jackwener/OpenCLI · error · CommandExecutionError
Failed to open facebook search: ${err instanceof Error ? err
Error message
Failed to open facebook search: ${err instanceof Error ? err.message : err} What it means
CommandExecutionError thrown by searchFacebook when navigating to facebook.com or the search results URL fails. The library first goes to the Facebook home page to warm the SPA, then to /search/top?q=..., and wraps any navigation error with a hint to check reachability and the browser extension connection. Extraction never runs if navigation fails.
Source
Thrown at clis/facebook/search.js:150
feedFound: !!document.querySelector('[role="feed"]'),
anchorCount: anchors.length,
mainTextLength: clean((document.querySelector('[role="main"]') || {}).textContent).length,
},
};
})()`;
}
async function searchFacebook(page, kwargs) {
const query = requireQuery(kwargs.query);
const limit = requireLimit(kwargs.limit ?? 10);
// Navigate home first so the SPA is warm, then to the search results.
// Regression guard for #625: extraction must run *after* this navigation.
try {
await page.goto(FACEBOOK_HOME);
await page.goto(`https://www.facebook.com/search/top?q=${encodeURIComponent(query)}`, { settleMs: 4000 });
} catch (err) {
throw new CommandExecutionError(
`Failed to open facebook search: ${err instanceof Error ? err.message : err}`,
'Check that facebook.com is reachable and the browser extension is connected.',
);
}
let payload;
try {
payload = unwrapBrowserResult(await page.evaluate(buildSearchExtractScript(limit)));
} catch (err) {
throw new CommandExecutionError(
`Failed to read facebook search results: ${err instanceof Error ? err.message : err}`,
'Facebook may not have rendered or the search markup may have changed.',
);
}
if (!payload || typeof payload !== 'object' || !Array.isArray(payload.rows)) {
throw new CommandExecutionError('facebook search returned malformed extraction payload');
}View on GitHub (pinned to 49907e53dc)
Solutions
- Verify facebook.com is reachable in the connected browser (open it manually)
- Reconnect/restart the browser extension that the CLI drives
- Check network connectivity, proxy, and firewall settings
- Re-run the command — transient network blips are common
- Check for an expired Facebook login redirecting to an error page
Example fix
// before: assuming navigation always succeeds
await page.goto(`https://www.facebook.com/search/top?q=${q}`);
// after: guard navigation and surface a actionable hint
try {
await page.goto(FACEBOOK_HOME);
await page.goto(`https://www.facebook.com/search/top?q=${encodeURIComponent(q)}`, { settleMs: 4000 });
} catch (err) {
throw new CommandExecutionError(
`Failed to open facebook search: ${err.message}`,
'Check that facebook.com is reachable and the browser extension is connected.',
);
} Defensive patterns
Strategy: try-catch
Validate before calling
// Reachability pre-check
const ok = await fetch('https://www.facebook.com', { method: 'HEAD' })
.then(r => r.ok).catch(() => false);
if (!ok) throw new Error('facebook.com is not reachable — check network/extension'); Type guard
function isNavigationFailure(e) {
return e instanceof Error && e.name === 'CommandExecutionError' &&
e.message.startsWith('Failed to open facebook search');
} Try / catch
try {
const results = await searchFacebook(query, limit);
} catch (err) {
if (/Failed to open facebook search/.test(err.message)) {
// retry after confirming connectivity/extension
await new Promise(r => setTimeout(r, 5000));
return searchFacebook(query, limit);
}
throw err;
} Prevention
- Verify the browser extension is connected before running commands
- Confirm facebook.com is reachable from your network/proxy
- Retry navigation failures with backoff
- Keep the driven browser logged in so redirects don't break navigation
When it happens
Trigger: page.goto to FACEBOOK_HOME or the encoded /search/top?q=<query> URL throws: network outage, DNS failure, timeout, or the browser extension/page is disconnected or closed.
Common situations: Corporate proxy or firewall blocking facebook.com; offline machine; browser extension not connected after a browser restart; page navigated away or closed mid-command; very slow connection exceeding the settle timeout.
Related errors
- `Failed to navigate to facebook feed: ${err instanceof Error
- Failed to navigate to facebook notifications: ${message}
- Failed to load Booking.com search page: ${err?.message || er
- Failed to open Chess.com analysis board: ${error?.message ||
- coupang product navigation failed: ${error?.message || error
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/b5666b538e958b7d.
Report an issue: GitHub.