{"record":{"id":"b06aa2645bd96a30","repo":"jackwener/OpenCLI","slug":"linkedin-cookie-lookup-failed-error-message","errorCode":null,"errorMessage":"LinkedIn cookie lookup failed: ${error?.message || error}","messagePattern":"LinkedIn cookie lookup failed: (.+?)","errorType":"error_code","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/linkedin/people-search.js","lineNumber":206,"sourceCode":"    ],\n    columns: ['rank', 'name', 'headline', 'location', 'profile_url'],\n    func: async (page, args) => {\n        if (!page) throw new CommandExecutionError('Browser session required for linkedin people-search');\n        const keywords = requireStringArg(args, 'keywords', '--keywords');\n        const limit = parseLimit(args.limit);\n\n        try {\n            await page.goto(buildSearchUrl(keywords));\n            await page.wait(6);\n        } catch (error) {\n            throw new CommandExecutionError(`LinkedIn people search navigation failed: ${error?.message || error}`);\n        }\n\n        let cookies;\n        try {\n            cookies = await page.getCookies({ url: 'https://www.linkedin.com' });\n        } catch (error) {\n            throw new CommandExecutionError(`LinkedIn cookie lookup failed: ${error?.message || error}`);\n        }\n        if (!Array.isArray(cookies)) {\n            throw new CommandExecutionError('LinkedIn cookie lookup returned malformed payload');\n        }\n        const jsession = cookies.find((c) => c.name === 'JSESSIONID')?.value;\n        if (!jsession) {\n            throw new AuthRequiredError(LINKEDIN_DOMAIN, 'LinkedIn JSESSIONID cookie not found. Please sign in to LinkedIn in the browser.');\n        }\n\n        let result;\n        try {\n            result = unwrapEvaluateResult(await page.evaluate(extractionScript()));\n        } catch (error) {\n            throw new CommandExecutionError(`LinkedIn people search extraction failed: ${error?.message || error}`);\n        }\n        if (result?.error) {\n            if (looksLinkedInAuthWall(`${result.url || ''} ${result.error || ''}`)) {\n                throw new AuthRequiredError(LINKEDIN_DOMAIN, 'LinkedIn people search requires an active signed-in browser session.');","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/linkedin/people-search.js#L188-L224","documentation":"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: ...'.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Re-run the command with a freshly launched browser session","Upgrade the automation client/driver so page.getCookies is supported","Ensure nothing (script, OS, user) closes the browser tab during the run","Check browser process logs for crashes (OOM, signal) between goto and getCookies"],"exampleFix":"// before: cookies fetched after a long, fragile gap\nawait page.goto(url); /* minutes later */ const cookies = await page.getCookies({...});\n// after: fetch cookies immediately after navigation, before any long waits\nawait page.goto(url);\nconst cookies = await page.getCookies({ url: 'https://www.linkedin.com' });","handlingStrategy":"try-catch","validationCode":"// verify the tab is still alive before cookie lookup\nawait page.goto('about:blank').catch(() => { throw new Error('browser tab is dead; relaunch session'); });","typeGuard":"null","tryCatchPattern":"try { cookies = await page.getCookies({ url: 'https://www.linkedin.com' }); }\ncatch (e) { if (/Target closed|Session closed|Protocol error/.test(String(e))) { await relaunchBrowser(); } throw e; }","preventionTips":["Don't close or kill the browser mid-run; use detached/headful sessions for long jobs","Monitor browser process health (crashes/OOM) during scraping batches","Keep the automation client up to date so getCookies is implemented","Re-read cookies promptly after navigation instead of much later"],"tags":["cookies","linkedin","browser-crash","cdp"],"backgroundTag":"cookie-lookup-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}