jackwener/OpenCLI · error · CommandExecutionError
Browser session required for facebook marketplace-inbox
Error message
Browser session required for facebook marketplace-inbox
What it means
The marketplace-inbox command requires a live browser session; if the page object is null when func runs, it throws CommandExecutionError('Browser session required for facebook marketplace-inbox'). COOKIE strategy commands need a connected browser extension session with Facebook cookies.
Source
Thrown at clis/facebook/marketplace-inbox.js:24
if (!Number.isInteger(limit) || limit <= 0) {
throw new ArgumentError('facebook marketplace-inbox --limit must be a positive integer');
}
return Math.min(limit, 100);
}
cli({
site: 'facebook',
name: 'marketplace-inbox',
access: 'read',
description: 'List recent Facebook Marketplace buyer/seller conversations',
domain: 'www.facebook.com',
strategy: Strategy.COOKIE,
args: [
{ name: 'limit', type: 'int', default: 20, help: 'Number of conversations to return' },
],
columns: ['index', 'buyer', 'listing', 'snippet', 'time', 'unread'],
func: async (page, args) => {
if (!page) throw new CommandExecutionError('Browser session required for facebook marketplace-inbox');
const limit = normalizeLimit(args.limit);
await page.goto('https://www.facebook.com/marketplace/inbox/');
await page.wait(4);
const result = await page.evaluate(String.raw`(() => {
const clean = (s) => String(s || '').replace(/[\u00a0\u202f]/g, ' ').replace(/\s+/g, ' ').trim();
const timeRe = /^(?:\d{1,2}:\d{2}\s?(?:AM|PM|am|pm|上午|下午)?|Mon|Tue|Wed|Thu|Fri|Sat|Sun|Today|Yesterday|\d+[mhdw]|\d+\s*(?:min|h|d|w))$/;
const text = document.body?.innerText || '';
if (/log in|sign in/i.test(text) && !/Marketplace/i.test(text)) {
return { authRequired: true, rows: [] };
}
const lines = text.split(/\n+/).map(clean).filter(Boolean);
const out = [];
const seen = new Set();
const skipBuyer = /^(Marketplace|Browse all|Notifications|Inbox|Marketplace access|Buying|Selling|Create new listing|Create multiple listings|Location|Categories|Vehicles|Property Rentals|All|Pending payment|Paid|To be shipped|Shipped|Cash on delivery|Completed|Filter by label)$/i;
for (let i = 0; i < lines.length - 2; i += 1) {
const buyer = lines[i];View on GitHub (pinned to 49907e53dc)
Solutions
- Launch the companion browser/extension session before running the command.
- Verify the extension is connected (check the CLI's session/connection status if available).
- In CI, set up the browser session (headed Chrome with the extension profile) as a prerequisite step.
- Re-authenticate if the browser session expired or was closed.
Example fix
// before await cli.run(['facebook', 'marketplace-inbox']); // page null // after await session.ensureBrowserConnected(); // start Chrome + extension first await cli.run(['facebook', 'marketplace-inbox']);
Defensive patterns
Strategy: try-catch
Validate before calling
// ensure the session exists before invoking const hasSession = await session.isConnected(); // extension/bridge check if (!hasSession) await session.launchBrowser();
Try / catch
try {
const items = await cli.run(['facebook', 'marketplace-inbox']);
} catch (err) {
if (/Browser session required/.test(err.message)) {
await session.launchBrowser(); // start Chrome + extension, then retry
} else throw err;
} Prevention
- Always launch the companion browser/extension before running browser-backed commands.
- Check session/connection status in scripts as a pre-step.
- In CI, provision the browser session as a prerequisite stage.
- Reconnect the session if the browser was closed between runs.
When it happens
Trigger: Invoking the command without an active browser session so the registry passes page = null into the command function — e.g. extension not connected, headed browser not launched, or headless mode without the session bridge.
Common situations: Running the CLI before starting the companion Chrome/extension; session died between runs; CI environment with no browser; forgetting to log in / launch the profile the CLI binds to.
Related errors
- Browser session required for facebook marketplace-listings
- 12306 whoami failed: ${probe.detail}
- Browser session required for bilibili comment
- Browser session required for bilibili summary
- Browser session required for instagram note
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/5b43395d2c526187.
Report an issue: GitHub.