jackwener/OpenCLI · error · CommandExecutionError

Browser session required for linkedin sent-invitations

Error message

Browser session required for linkedin sent-invitations

What it means

The sent-invitations command is registered with browser: true and Strategy.UI, meaning it needs a live browser page. If the CLI runtime invokes the command's func without a page object (no browser could be launched or the session was not created), the func immediately throws this CommandExecutionError rather than dereferencing null.

Source

Thrown at clis/linkedin/sent-invitations.js:91

      malformedCount,
      count: rows.length,
      rows,
    };
  })()`;
}

cli({
  site: 'linkedin',
  name: 'sent-invitations',
  access: 'read',
  description: 'List pending LinkedIn sent invitations for CRM reconciliation',
  domain: LINKEDIN_DOMAIN,
  strategy: Strategy.UI,
  browser: true,
  args: [],
  columns: ['rank', 'name', 'profile_url', 'invited_date_text'],
  func: async (page) => {
    if (!page) throw new CommandExecutionError('Browser session required for linkedin sent-invitations');
    await page.goto(SENT_URL);
    await page.wait(12);
    let result = unwrapEvaluateResult(await page.evaluate(buildSentInvitationsScript()));
    if (result?.authRequired) {
      throw new AuthRequiredError(LINKEDIN_DOMAIN, 'LinkedIn sent invitations requires an active signed-in browser session.');
    }
    if (result?.warning) {
      throw new CommandExecutionError('LinkedIn warning/restriction state visible on sent invitations page.');
    }
    if (!result || typeof result !== 'object' || Array.isArray(result) || !Array.isArray(result.rows)) {
      throw new CommandExecutionError('LinkedIn sent invitations returned a malformed extraction payload.');
    }
    if (result.malformedCount > 0) {
      throw new CommandExecutionError('LinkedIn sent invitations contained a malformed invitation card.');
    }
    const rows = result.rows;
    if (rows.length === 0) {
      if (result.explicitEmpty) {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Ensure a Chromium/Chrome browser is installed and launchable in the environment, then re-run the command.
  2. Check CLI/browser provisioning logs for the underlying launch failure (missing display, missing --no-sandbox, crashed binary) and fix that root cause.
  3. Run in an environment with a display or proper headless flags (e.g. xvfb, --headless=new, --no-sandbox).
  4. If calling the func programmatically, always pass a live page from the CLI session instead of undefined.

Example fix

// before (no display in CI -> page is null)
// CI: npx opencli linkedin sent-invitations
// after — provide a virtual display / headless browser
// CI install: apt-get install -y chromium xvfb
// CI run: xvfb-run npx opencli linkedin sent-invitations
Defensive patterns

Strategy: fallback

Validate before calling

// Verify a browser is available before invoking UI-strategy commands
import { executablePath } from '...'; // or check chromium on PATH
import { existsSync } from 'fs';
if (!existsSync(chromiumPath)) {
  console.error('Chromium not found; install it or set the browser path before running linkedin sent-invitations.');
  process.exit(1);
}

Type guard

const hasLivePage = (page) => Boolean(page) && typeof page.goto === 'function' && typeof page.evaluate === 'function';

Try / catch

let rows;
try {
  rows = await run(['linkedin', 'sent-invitations']);
} catch (e) {
  if (/Browser session required/.test(e.message)) {
    console.error('Browser could not be provisioned. Install Chromium / configure headless flags, then retry.');
    process.exit(3);
  }
  throw e;
}

Prevention

When it happens

Trigger: Invoking `opencli linkedin sent-invitations` in an environment where the browser-backed session could not be established (browser launch failure, headless environment without a browser binary, session pool returning null page), so func receives page === null/undefined.

Common situations: Running on a server/CI without Chrome/Chromium installed; browser launch crashing due to missing sandbox dependencies; misconfigured CLI runtime that skips browser provisioning for UI-strategy commands; running the command outside the CLI harness with page omitted.

Related errors


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