jackwener/OpenCLI · error · CommandExecutionError

`Failed to read facebook feed: ${err instanceof Error ? err.

Error message

`Failed to read facebook feed: ${err instanceof Error ? err.message : err}`

What it means

After navigating, getFacebookFeed runs an in-page extraction script via page.evaluate and unwraps the browser result; any failure there (script error, browser not returning a valid result) is rethrown as a CommandExecutionError with a hint that Facebook may not have rendered or the feed markup changed. It separates 'could not run extraction' from 'extraction ran but found nothing'.

Source

Thrown at clis/facebook/feed.js:361

async function getFacebookFeed(page, kwargs) {
  const limit = requireLimit(kwargs.limit ?? 10);
  try {
    await page.goto(FACEBOOK_HOME, { settleMs: 4000 });
  } catch (err) {
    throw new CommandExecutionError(
      `Failed to navigate to facebook feed: ${err instanceof Error ? err.message : err}`,
      'Check that facebook.com is reachable and the browser extension is connected.',
    );
  }

  await loadFeedPosts(page, limit);

  let payload;
  try {
    payload = unwrapBrowserResult(await page.evaluate(buildFeedExtractScript(limit)));
  } catch (err) {
    throw new CommandExecutionError(
      `Failed to read facebook feed: ${err instanceof Error ? err.message : err}`,
      'Facebook may not have rendered or the feed markup may have changed.',
    );
  }

  if (!payload || typeof payload !== 'object' || !Array.isArray(payload.rows)) {
    throw new CommandExecutionError('facebook feed returned malformed extraction payload');
  }

  if (payload.status === 'auth') {
    throw new AuthRequiredError('www.facebook.com', 'Open Chrome and log in to Facebook before retrying.');
  }

  if (payload.rows.length > 0) {
    return payload.rows;
  }

  if (payload.status === 'empty') {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Retry the command after confirming the feed page fully loads in the connected browser.
  2. Check that you are not stuck on a login/checkpoint page (see the auth error path).
  3. Update the CLI and browser extension to matching versions so page.evaluate/unwrapBrowserResult protocols agree.
  4. If persistent, inspect whether Facebook's feed DOM changed and update the extraction script.

Example fix

// before
const payload = unwrapBrowserResult(await page.evaluate(buildFeedExtractScript(limit)));
// after
let payload;
try {
  payload = unwrapBrowserResult(await page.evaluate(buildFeedExtractScript(limit)));
} catch (err) {
  await page.wait(2);
  payload = unwrapBrowserResult(await page.evaluate(buildFeedExtractScript(limit)));
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
  const rows = await getFacebookFeed(page, { limit: 10 });
} catch (err) {
  if (/Failed to read facebook feed/.test(err.message)) {
    await page.wait(2);
    // retry once; if persistent, check for login wall or update CLI
  } else throw err;
}

Prevention

When it happens

Trigger: unwrapBrowserResult(await page.evaluate(buildFeedExtractScript(limit))) throws: the evaluate call rejects (page navigated away, crashed tab, script runtime error), or the browser extension returned an unexpected result shape that unwrapBrowserResult rejects.

Common situations: Facebook redirects to a login/checkpoint page mid-load; heavy page redraw invalidates execution context; extension protocol mismatch after a browser update; partial page render under slow network.

Related errors


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