jackwener/OpenCLI · error · EmptyResultError
facebook/notifications
Error message
facebook/notifications
What it means
CommandExecutionError thrown by getFacebookNotifications when extracting notifications from the facebook.com page fails. The library wraps the error because scraping depends on Facebook's DOM, which may not render or may have changed. It carries a hint that the page may not have rendered or the markup may have changed. An EmptyResultError variant is thrown instead when extraction succeeded but returned no rows.
Source
Thrown at clis/facebook/notifications.js:302
}
let rows;
try {
rows = await page.evaluate(buildNotificationsScript(limit));
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
if (/AUTH_REQUIRED/i.test(message)) {
throw new AuthRequiredError(
'facebook.com',
'Open Chrome and log in to Facebook before retrying',
);
}
throw new CommandExecutionError(
`Failed to read facebook notifications: ${message}`,
'facebook.com page may not have rendered or markup may have changed',
);
}
if (!Array.isArray(rows) || rows.length === 0) {
throw new EmptyResultError(
'facebook/notifications',
'No notifications found — login session may have expired or you have no recent notifications',
);
}
return rows;
}
export const notificationsCommand = cli({
site: 'facebook',
name: 'notifications',
access: 'read',
description: 'Get recent Facebook notifications (含 unread / time / url / notif_id / notif_type 列)',
domain: 'www.facebook.com',
strategy: Strategy.COOKIE,
browser: true,
navigateBefore: false,
args: [
{View on GitHub (pinned to 49907e53dc)
Solutions
- Re-run the command — transient render delays are the most common cause
- Log in to facebook.com in the connected browser to refresh an expired session
- Check the connected browser extension is running and reachable
- Update the library in case Facebook changed its notifications markup and selectors were fixed
- Verify network access to facebook.com
Example fix
// before: swallowing navigation errors so extraction runs on a blank page
await page.goto('https://www.facebook.com/notifications');
const rows = await page.evaluate(extractNotifications);
// after: ensure page settles and handle the error explicitly
await page.goto('https://www.facebook.com/notifications', { settleMs: 4000 });
try {
const rows = await page.evaluate(extractNotifications);
} catch (err) {
throw new CommandExecutionError(
`Failed to read facebook notifications: ${err.message}`,
'facebook.com page may not have rendered or markup may have changed',
);
} Defensive patterns
Strategy: try-catch
Validate before calling
// Best-effort pre-checks before calling
if (typeof navigator !== 'undefined' && !navigator.onLine) throw new Error('offline');
// Ensure an authenticated facebook.com session exists in the connected browser before scraping Type guard
function isCommandExecutionError(e) {
return e instanceof Error && e.name === 'CommandExecutionError';
} Try / catch
try {
const rows = await getFacebookNotifications();
} catch (err) {
if (/Failed to read facebook notifications/.test(err.message)) {
// wait and retry once for transient render delays
await new Promise(r => setTimeout(r, 3000));
return getFacebookNotifications();
}
throw err;
} Prevention
- Keep an active facebook.com login in the driven browser
- Retry once with a delay to absorb render timing races
- Keep the library updated for Facebook markup changes
- Check browser extension connectivity before long scraping runs
When it happens
Trigger: Running the facebook/notifications command when page.evaluate/extraction throws: the notifications page failed to load, the DOM selectors no longer match, or the page render timed out.
Common situations: Facebook ships a markup change breaking selectors; slow network causing the page not to render in time; login redirect or checkpoint page shown instead of notifications; browser extension/browser disconnected mid-run.
Related errors
- Failed to read facebook search results: ${err instanceof Err
- 1point3acres request failed: ${error?.message || error}
- 1point3acres request failed: HTTP ${res.status} ${res.status
- Barchart greeks request failed: HTTP ${data.status}${data.st
- Ctrip round-trip flight DOM extraction returned malformed ro
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/3247ec56114a91f7.
Report an issue: GitHub.