{"record":{"id":"668a4bd8f8938953","repo":"jackwener/OpenCLI","slug":"linkedin-people-search-extraction-failed-error","errorCode":null,"errorMessage":"LinkedIn people search extraction failed: ${error?.message || error}","messagePattern":"LinkedIn people search extraction failed: (.+?)","errorType":"error_code","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/linkedin/people-search.js","lineNumber":220,"sourceCode":"        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.');\n            }\n            // If LinkedIn redirected away from the search page that\n            // usually means CUL was reached or the account is gated.\n            throw new CommandExecutionError(`LinkedIn redirected away from the search page (${result.error}). Likely Commercial Use Limit reached - the limit resets on the 1st of next month.`);\n        }\n        if (!result || typeof result !== 'object') {\n            throw new CommandExecutionError('LinkedIn people search returned malformed extraction payload');\n        }\n        const candidateCount = parseNonNegativeCount(result.candidate_count, 'candidate_count');\n        parseNonNegativeCount(result.person_entries_count, 'person_entries_count');\n        const resolvedCount = parseNonNegativeCount(result.resolved_count, 'resolved_count');\n        const rows = normalizePeopleRows(result.rows);\n        if (rows.length === 0 && (candidateCount > 0 || resolvedCount > 0)) {\n            throw new CommandExecutionError('LinkedIn people search found profile candidates but could not parse stable result rows');","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/linkedin/people-search.js#L202-L238","documentation":"The in-page extraction script runs via page.evaluate and its result is unwrapped by unwrapEvaluateResult. If evaluate itself throws (script error, execution context destroyed, page closed, serialization failure), the command rethrows as CommandExecutionError 'LinkedIn people search extraction failed: ...'.","triggerScenarios":"page.evaluate(extractionScript()) throws — the page navigated/closed during evaluation, execution context invalidated by a client-side redirect, a syntax/runtime error in the injected script, or the result was not serializable (function/DOM node returned).","commonSituations":"LinkedIn client-side redirects firing while the script runs; evaluating on about:blank or an error page; automation client choking on non-serializable evaluate return values; heavy page JS throwing before the extractor finishes.","solutions":["Retry the command — transient redirects/JS races often clear on a second run","Re-run in a signed-in session so the real search page (stable DOM) loads","Update the package so extractionScript() matches current LinkedIn markup","Ensure evaluate only returns plain JSON-serializable data","Increase post-navigation wait so redirects settle before evaluation"],"exampleFix":"// before: evaluate immediately after goto, redirect kills context\nawait page.goto(url); await page.wait(6); result = await page.evaluate(script);\n// after: longer settle wait\nawait page.goto(url); await page.wait(10); result = await page.evaluate(script);","handlingStrategy":"try-catch","validationCode":"// only evaluate on the live search page\nconst currentUrl = await page.url?.();\nif (!currentUrl || !currentUrl.includes('linkedin.com')) throw new Error('not on a LinkedIn page; skipping evaluate');","typeGuard":"null","tryCatchPattern":"try { result = unwrapEvaluateResult(await page.evaluate(extractionScript())); }\ncatch (e) { if (/Execution context was destroyed|Target closed/.test(String(e))) { await page.wait(5); return retryOnce(); } throw e; }","preventionTips":["Wait for page stability (redirects finished) before evaluating","Keep evaluate return values plain and JSON-serializable","Retry once on context-destroyed errors — they are often transient","Keep the CLI updated so the injected script matches current LinkedIn JS"],"tags":["linkedin","page-evaluate","dom-parsing","javascript"],"backgroundTag":"page-evaluate-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}