jackwener/OpenCLI · error · CommandExecutionError

Browser session required for instagram reel

Error message

Browser session required for instagram reel

What it means

requirePage asserts that a browser page object exists before any Instagram reel posting work begins. The CLI operates a real browser session; if the page handle is null/undefined there is no browser to drive, so it throws a CommandExecutionError immediately. This is a fail-fast guard, not a report of a failed operation.

Source

Thrown at clis/instagram/reel.js:14

import * as fs from 'node:fs';
import * as os from 'node:os';
import * as path from 'node:path';
import { Page as BrowserPage } from '@jackwener/opencli/browser/page';
import { cli, Strategy } from '@jackwener/opencli/registry';
import { ArgumentError, AuthRequiredError, CommandExecutionError } from '@jackwener/opencli/errors';
import { buildClickActionJs, buildEnsureComposerOpenJs, buildInspectUploadStageJs, } from './post.js';
import { resolveCurrentUserId, resolveInstagramRuntimeInfo } from './_shared/runtime-info.js';
import { INSTAGRAM_HOME_URL, gotoInstagramHome } from './_shared/navigation.js';
const SUPPORTED_VIDEO_EXTENSIONS = new Set(['.mp4']);
const INSTAGRAM_REEL_TIMEOUT_SECONDS = 600;
function requirePage(page) {
    if (!page)
        throw new CommandExecutionError('Browser session required for instagram reel');
    return page;
}
function validateVideoPath(input) {
    const resolved = path.resolve(String(input || '').trim());
    if (!resolved) {
        throw new ArgumentError('Video path cannot be empty');
    }
    if (!fs.existsSync(resolved)) {
        throw new ArgumentError(`Video file not found: ${resolved}`);
    }
    const ext = path.extname(resolved).toLowerCase();
    if (!SUPPORTED_VIDEO_EXTENSIONS.has(ext)) {
        throw new ArgumentError(`Unsupported video format: ${ext}`, 'Supported formats: .mp4');
    }
    return resolved;
}
function validateInstagramReelArgs(kwargs) {
    if (kwargs.video === undefined) {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Ensure the browser session is started/connected before running the reel command (verify browserPage launches a page successfully).
  2. Check that the browser binary is installed and reachable in the environment.
  3. If using Browser Bridge, confirm the bridge is running and paired before invoking the command.
  4. Wrap browserPage creation so a null page is logged with launch diagnostics instead of silently propagated.

Example fix

// before
await runReel(page); // page may be undefined
// after
const page = await browserPage();
if (!page) throw new Error('Browser did not start; check browser binary/bridge');
await runReel(page);
Defensive patterns

Strategy: type-guard

Validate before calling

if (!page || typeof page.evaluate !== 'function') throw new Error('No browser page available; start the browser session first');

Type guard

function hasPage(page) { return !!page && typeof page.evaluate === 'function' && typeof page.wait === 'function'; }

Try / catch

try { await runReel(args); } catch (e) { if (e.message.includes('Browser session required')) { await restartBrowserSession(); return runReel(args); } throw e; }

Prevention

When it happens

Trigger: Calling the instagram reel command when the underlying browser page is null/undefined — e.g. browserPage failed to launch or return a page, or the reel flow was invoked without an active browser session.

Common situations: Browser (Chromium/Playwright bridge) failed to start, headless environment missing the browser binary, Browser Bridge not connected, or a code path passing the result of a failed page lookup straight into requirePage.

Related errors


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