jackwener/OpenCLI · error · CommandExecutionError
Browser session required for weibo publish
Error message
Browser session required for weibo publish
What it means
The publish command runs through a browser session provided by a Chrome extension; if the `page` handle is not available (no browser session attached), func throws this CommandExecutionError before doing anything.
Source
Thrown at clis/weibo/publish.js:96
browser: true,
args: [
{
name: 'text',
type: 'string',
required: true,
positional: true,
help: 'Weibo text content (max 2000 chars)',
},
{
name: 'images',
type: 'string',
required: false,
help: `Image paths, comma-separated, max ${MAX_IMAGES} (jpg/png/gif/webp)`,
},
],
columns: ['status', 'message', 'text'],
func: async (page, kwargs) => {
if (!page) throw new CommandExecutionError('Browser session required for weibo publish');
const text = validateText(kwargs.text);
const absPaths = validateImagePaths(kwargs.images);
// Step 1: Navigate to weibo.com and wait for feed to load
await page.goto('https://weibo.com', { waitUntil: 'load', settleMs: 2000 });
await page.wait({ time: 2 });
// Step 2: Check login
try {
await getSelfUid(page);
} catch (err) {
if (err instanceof AuthRequiredError) throw err;
throw new CommandExecutionError('Not logged into Weibo. Please login at weibo.com in your Chrome browser.');
}
// Step 3: Click "发微博" button to open inline compose editor
const clickResult = await page.evaluate(`View on GitHub (pinned to 49907e53dc)
Solutions
- Install/enable the companion Chrome extension and reconnect the session
- Start a browser session before running the publish command
- Update the extension and CLI to matching versions
Example fix
// before weibo publish --text "hi" # no session // after <open managed Chrome session with extension> weibo publish --text "hi"
Defensive patterns
Strategy: fallback
Validate before calling
// ensure a managed browser session exists before invoking the CLI
if (!session || !session.page) {
throw new Error('start the browser session / install the extension first');
} Type guard
function hasPage(ctx) {
return ctx != null && typeof ctx === 'object' && typeof ctx.page === 'object' && ctx.page !== null;
} Try / catch
try {
await cli.run(['weibo', 'publish', '--text', text]);
} catch (err) {
if (/Browser session required/.test(err.message)) {
await startBrowserSession(); // connect Chrome with extension
// then retry
} else throw err;
} Prevention
- Install and enable the companion Chrome extension
- Always open the managed session before publish commands
- Keep extension and CLI versions in sync
When it happens
Trigger: Running `weibo publish` outside a connected browser session — extension not installed/disabled, no active Chrome tab managed by the tool, or session dropped before the call.
Common situations: Running in CI without the extension; forgetting to start/connect the browser session; the extension failing to inject after a Chrome update.
Related errors
- ChatGPT did not create a conversation URL after sending the
- Grok composer rejected the prompt: ${JSON.stringify(sendResu
- ${before.reason || `Failed to inspect ${name} state.`}${deta
- Browser session required
- Unexpected Manus probe: ${JSON.stringify(probe)}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/ecba475dbf95d21c.
Report an issue: GitHub.