jackwener/OpenCLI · error · AuthRequiredError

facebook.com

Error message

facebook.com

What it means

AuthRequiredError('facebook.com', 'Open Chrome and log in to Facebook before retrying') thrown by getFacebookNotifications when the injected evaluate script fails with a message matching /AUTH_REQUIRED/. This is the user-facing translation of the script-level 'AUTH_REQUIRED: facebook.com redirected to login' error (see 1406).

Source

Thrown at clis/facebook/notifications.js:291

async function getFacebookNotifications(page, args) {
    const limit = normalizeNotificationsLimit(args.limit);
    try {
        await page.goto(`${FB_HOST}/notifications`, { waitUntil: 'load', settleMs: 3000 });
    } 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;
}

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Open Chrome and log in to Facebook, then re-run the notifications command
  2. Confirm facebook.com/notifications loads without redirecting to login in that profile
  3. Complete any Facebook security/2FA checkpoint blocking the session
  4. Persist the profile (user-data-dir) so cookies survive restarts
Defensive patterns

Strategy: try-catch

Validate before calling

const path = await page.evaluate(String.raw`(() => window.location.pathname)()`);
if (/login|checkpoint/.test(path)) throw new Error('AUTH_REQUIRED');

Type guard

const isAuthRequiredError = (e) => e instanceof Error && (e.name === 'AuthRequiredError' || /AUTH_REQUIRED/i.test(e.message));

Try / catch

try {
  const rows = await getFacebookNotifications(page, args);
} catch (e) {
  if (isAuthRequiredError(e)) {
    console.error('Open Chrome and log in to Facebook before retrying');
  } else throw e;
}

Prevention

When it happens

Trigger: Running the notifications command while the browser profile has no valid signed-in facebook.com session, so the script detected it was on a login/redirect path and threw AUTH_REQUIRED.

Common situations: Session cookies expired overnight; logged out of the profile browser; Facebook invalidated the session (password change, security checkpoint); automation running on a profile that was never logged in.

Related errors


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