jackwener/OpenCLI · error · CommandExecutionError
Failed to read facebook notifications: ${message}
Error message
Failed to read facebook notifications: ${message} What it means
CommandExecutionError thrown when page.evaluate(buildNotificationsScript(limit)) fails for any reason other than AUTH_REQUIRED. The inner message is interpolated and a hint ('facebook.com page may not have rendered or markup may have changed') is attached, distinguishing page-structure failures from auth and navigation failures.
Source
Thrown at clis/facebook/notifications.js:296
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
throw new CommandExecutionError(
`Failed to navigate to facebook notifications: ${message}`,
'facebook.com may be unreachable',
);
}
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 列)',View on GitHub (pinned to 49907e53dc)
Solutions
- Read the interpolated inner message to identify the exact evaluate failure
- Re-run after giving the page more time to render (SPA list items render late)
- Reload the notifications page in the managed browser and verify rows render manually
- If markup changed, update buildNotificationsScript/extract helpers to match current Facebook DOM
Defensive patterns
Strategy: try-catch
Validate before calling
// Give the SPA time to render, then sanity-check the DOM before evaluate
await page.wait(3);
const rendered = await page.evaluate(String.raw`(() => !!document.querySelector('[role="listitem"]'))()`); Try / catch
try {
const rows = await getFacebookNotifications(page, args);
} catch (e) {
if (/Failed to read facebook notifications/.test(e.message)) {
// DOM/markup issue: re-run with longer wait or update extraction selectors
await page.reload(); await retryWithLongerWait();
} else throw e;
} Prevention
- Inspect the interpolated inner message for the exact evaluate failure
- Wait for list rows to render before scraping the SPA
- Pin/update extraction selectors after Facebook markup changes
- Disable extensions that mutate the DOM in the automation profile
When it happens
Trigger: The evaluate script throwing due to unexpected Facebook DOM (missing roles/selectors), script runtime errors, the page not rendering notification rows in time, or evaluate timing out/crashing.
Common situations: Facebook UI/markup update breaking the extraction helpers (stripMarkAsReadPrefix, extractNotificationRowsFromDoc); SPA still loading when the script ran; ad-blocker or extension altering the DOM; page crashed during evaluate.
Related errors
- dianping search parser found no result-shaped shop cards
- dianping search parser found result cards without shop_id va
- dianping ${contextHint} did not render expected data${sample
- facebook marketplace-inbox
- facebook marketplace-listings
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/39a20d50e7c54386.
Report an issue: GitHub.