jackwener/OpenCLI · error · CommandExecutionError
LinkedIn people search extraction failed: ${error?.message |
Error message
LinkedIn people search extraction failed: ${error?.message || error} What it means
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: ...'.
Source
Thrown at clis/linkedin/people-search.js:220
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.');
}
// If LinkedIn redirected away from the search page that
// usually means CUL was reached or the account is gated.
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.`);
}
if (!result || typeof result !== 'object') {
throw new CommandExecutionError('LinkedIn people search returned malformed extraction payload');
}
const candidateCount = parseNonNegativeCount(result.candidate_count, 'candidate_count');
parseNonNegativeCount(result.person_entries_count, 'person_entries_count');
const resolvedCount = parseNonNegativeCount(result.resolved_count, 'resolved_count');
const rows = normalizePeopleRows(result.rows);
if (rows.length === 0 && (candidateCount > 0 || resolvedCount > 0)) {
throw new CommandExecutionError('LinkedIn people search found profile candidates but could not parse stable result rows');View on GitHub (pinned to 49907e53dc)
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
Example fix
// before: evaluate immediately after goto, redirect kills context await page.goto(url); await page.wait(6); result = await page.evaluate(script); // after: longer settle wait await page.goto(url); await page.wait(10); result = await page.evaluate(script);
Defensive patterns
Strategy: try-catch
Validate before calling
// only evaluate on the live search page
const currentUrl = await page.url?.();
if (!currentUrl || !currentUrl.includes('linkedin.com')) throw new Error('not on a LinkedIn page; skipping evaluate'); Type guard
null
Try / catch
try { result = unwrapEvaluateResult(await page.evaluate(extractionScript())); }
catch (e) { if (/Execution context was destroyed|Target closed/.test(String(e))) { await page.wait(5); return retryOnce(); } throw e; } Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- LinkedIn Learning whoami failed: ${result.detail}
- LinkedIn people search returned malformed extraction payload
- LinkedIn people search returned malformed extraction payload
- LinkedIn people search found profile candidates but could no
- LinkedIn sent invitations contained a malformed invitation c
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/668a4bd8f8938953.
Report an issue: GitHub.