jackwener/OpenCLI · error · CommandExecutionError

LinkedIn cookie lookup failed: ${error?.message || error}

Error message

LinkedIn cookie lookup failed: ${error?.message || error}

What it means

After navigating, the command reads browser cookies via page.getCookies({ url: 'https://www.linkedin.com' }) to obtain the JSESSIONID needed for authenticated API calls. If that call itself throws (page crashed, target closed, protocol error), it is rethrown as CommandExecutionError 'LinkedIn cookie lookup failed: ...'.

Source

Thrown at clis/linkedin/people-search.js:206

    ],
    columns: ['rank', 'name', 'headline', 'location', 'profile_url'],
    func: async (page, args) => {
        if (!page) throw new CommandExecutionError('Browser session required for linkedin people-search');
        const keywords = requireStringArg(args, 'keywords', '--keywords');
        const limit = parseLimit(args.limit);

        try {
            await page.goto(buildSearchUrl(keywords));
            await page.wait(6);
        } catch (error) {
            throw new CommandExecutionError(`LinkedIn people search navigation failed: ${error?.message || error}`);
        }

        let cookies;
        try {
            cookies = await page.getCookies({ url: 'https://www.linkedin.com' });
        } catch (error) {
            throw new CommandExecutionError(`LinkedIn cookie lookup failed: ${error?.message || error}`);
        }
        if (!Array.isArray(cookies)) {
            throw new CommandExecutionError('LinkedIn cookie lookup returned malformed payload');
        }
        const jsession = cookies.find((c) => c.name === 'JSESSIONID')?.value;
        if (!jsession) {
            throw new AuthRequiredError(LINKEDIN_DOMAIN, 'LinkedIn JSESSIONID cookie not found. Please sign in to LinkedIn in the browser.');
        }

        let result;
        try {
            result = unwrapEvaluateResult(await page.evaluate(extractionScript()));
        } catch (error) {
            throw new CommandExecutionError(`LinkedIn people search extraction failed: ${error?.message || error}`);
        }
        if (result?.error) {
            if (looksLinkedInAuthWall(`${result.url || ''} ${result.error || ''}`)) {
                throw new AuthRequiredError(LINKEDIN_DOMAIN, 'LinkedIn people search requires an active signed-in browser session.');

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Re-run the command with a freshly launched browser session
  2. Upgrade the automation client/driver so page.getCookies is supported
  3. Ensure nothing (script, OS, user) closes the browser tab during the run
  4. Check browser process logs for crashes (OOM, signal) between goto and getCookies

Example fix

// before: cookies fetched after a long, fragile gap
await page.goto(url); /* minutes later */ const cookies = await page.getCookies({...});
// after: fetch cookies immediately after navigation, before any long waits
await page.goto(url);
const cookies = await page.getCookies({ url: 'https://www.linkedin.com' });
Defensive patterns

Strategy: try-catch

Validate before calling

// verify the tab is still alive before cookie lookup
await page.goto('about:blank').catch(() => { throw new Error('browser tab is dead; relaunch session'); });

Type guard

null

Try / catch

try { cookies = await page.getCookies({ url: 'https://www.linkedin.com' }); }
catch (e) { if (/Target closed|Session closed|Protocol error/.test(String(e))) { await relaunchBrowser(); } throw e; }

Prevention

When it happens

Trigger: page.getCookies throws — the browser target/tab closed, a CDP/protocol error occurred, the page navigated away destroying the context, or the automation client does not implement getCookies with the url filter.

Common situations: Browser crashed or was closed by the user mid-run; headless browser killed by OOM; automation driver version mismatch lacking getCookies support; running the command after the session expired and the tab was torn down.

Related errors


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