jackwener/OpenCLI · error · CommandExecutionError
Browser session required for linkedin connect
Error message
Browser session required for linkedin connect
What it means
The linkedin connect command is a browser-session command: its func receives the active Playwright-like page. If page is null/undefined the command cannot drive LinkedIn and throws CommandExecutionError immediately, before any argument validation.
Source
Thrown at clis/linkedin/connect.js:414
}
cli({
site: 'linkedin',
name: 'connect',
access: 'write',
description: 'Fail-closed LinkedIn connection request sender that verifies the exact profile before optionally sending a note',
domain: LINKEDIN_DOMAIN,
strategy: Strategy.UI,
browser: true,
args: [
{ name: 'profile-url', type: 'string', required: true, positional: true, help: 'Exact LinkedIn profile URL to open and verify' },
{ name: 'expected-name', type: 'string', required: true, help: 'Expected visible profile name' },
{ name: 'note', type: 'string', required: false, default: '', help: 'Optional connection note, max 300 chars' },
{ name: 'send', type: 'bool', required: false, default: false, help: 'Actually click Send. Default is dry-run verification only.' },
],
columns: ['status', 'recipient', 'reason', 'profile_url', 'note_chars', 'connectable', 'delivery_verified', 'matched_invitation_name', 'matched_invitation_url', 'actualValue', 'blockReason', 'expectedValue', 'observedUrl', 'safety'],
func: async (page, args) => {
if (!page) throw new CommandExecutionError('Browser session required for linkedin connect');
const profileUrl = requireLinkedInProfileUrl(requireStringArg(args, 'profile-url', '--profile-url'), '--profile-url');
const expectedName = requireStringArg(args, 'expected-name', '--expected-name');
const note = clampNote(args.note || '');
await page.goto(profileUrl);
await page.wait(6);
let probe = await probeProfile(page, expectedName);
// The name resolves early (from document.title), but the profile action
// buttons (Connect / Message / Pending) render later. Keep probing until
// the action state has resolved, not merely until the name is visible.
for (let attempt = 0; attempt < 8; attempt += 1) {
const resolved = probe?.name
&& (probe.connectAvailable || probe.alreadyConnected || probe.pending || probe.moreAvailable);
if (resolved) break;
await page.wait(2);
probe = await probeProfile(page, expectedName);
}
const safety = assessProfileSafety(probe, expectedName, profileUrl);View on GitHub (pinned to 49907e53dc)
Solutions
- Launch the browser session (the library's browser harness) before invoking linkedin connect
- Run the command through the normal CLI entry point so the session is created and passed in
- If invoking programmatically, pass a real page instance as the first argument to func
- Check earlier logs for browser launch failures (missing browser binary, sandbox issues) that left the session unset
Example fix
// before
await command.func(null, args);
// after
const { page } = await startBrowserSession();
await command.func(page, args); Defensive patterns
Strategy: try-catch
Validate before calling
if (!page || typeof page.goto !== 'function') throw new Error('Cannot run linkedin connect: no active browser page. Start the browser session first.'); Type guard
function hasBrowserPage(p) { return p != null && typeof p.goto === 'function' && typeof p.evaluate === 'function'; } Try / catch
try { await connectCommand.func(page, args); } catch (e) { if (String(e.message).includes('Browser session required')) { await startBrowserSession(); /* retry once */ } else { throw e; } } Prevention
- Always launch the browser session before invoking browser-scoped commands
- Route browser commands through the library's CLI/runner instead of calling func directly
- Check startup logs for silent browser-launch failures
- Guard programmatic calls with a hasBrowserPage check
When it happens
Trigger: Invoking the linkedin connect command outside a browser session context — e.g. calling the CLI subcommand directly without launching the headless browser harness, or wiring the command's func with no page argument.
Common situations: Running the command through a driver/runner that skips browser session creation; calling the exported command object programmatically with (null, args); misconfigured CLI bootstrap where the browser failed to launch but commands still dispatch.
Related errors
- Browser session required for linkedin-learning trending
- Browser session required for bilibili follow
- Browser session required for bilibili following
- No turns were visible after navigating to ${target}.
- 'gemini read','No Gemini conversation links were visible in
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/13354e5904a9af00.
Report an issue: GitHub.