jackwener/OpenCLI · error · CommandExecutionError
Browser session required for linkedin job-detail
Error message
Browser session required for linkedin job-detail
What it means
CommandExecutionError thrown when the linkedin job-detail command's func is invoked without a browser page object. This command is declared with browser:true so it only works inside a logged-in browser session; the throw is a fail-fast guard at clis/linkedin/job-detail.js:153 before any navigation happens. It indicates the CLI harness did not supply a page, meaning the command was run outside a browser-enabled context or the session failed to initialize.
Source
Thrown at clis/linkedin/job-detail.js:153
url: normalizeHttpUrl(row.url),
description: normalizeWhitespace(row.description),
};
}
cli({
site: 'linkedin',
name: 'job-detail',
access: 'read',
description: 'Read one LinkedIn job page with description, apply URL, workplace type, applicants, and company metadata',
domain: 'www.linkedin.com',
strategy: Strategy.COOKIE,
browser: true,
args: [
{ name: 'job-url', type: 'string', required: true, positional: true, help: 'Exact LinkedIn job URL, e.g. https://www.linkedin.com/jobs/view/123/' },
],
columns: ['title', 'company', 'location', 'workplace_type', 'job_type', 'applicants', 'listed', 'apply_url', 'company_url', 'url', 'description'],
func: async (page, args) => {
if (!page) throw new CommandExecutionError('Browser session required for linkedin job-detail');
const jobUrl = normalizeJobUrl(args['job-url']);
await page.goto(jobUrl);
await page.wait(4);
await assertLinkedInAuthenticated(page, 'LinkedIn job-detail');
const row = unwrapEvaluateResult(await page.evaluate(buildExtractionScript()));
return [normalizeDetail(row)];
},
});
export const __test__ = {
normalizeJobUrl,
decodeLinkedinRedirect,
normalizeDetail,
};
View on GitHub (pinned to 49907e53dc)
Solutions
- Launch the command through the normal CLI path so the browser:true flag spins up a page before func runs
- Ensure LinkedIn cookies for www.linkedin.com are configured and valid so the session starts
- Check browser launch logs/dependencies (Chromium installed, not blocked in sandbox) if the session silently fails
- When calling func directly in tests, pass a stub page object satisfying goto/wait/evaluate
Example fix
// before
await commands['linkedin/job-detail'].func(null, { 'job-url': 'https://www.linkedin.com/jobs/view/123/' });
// after
const page = await startBrowserSession({ cookies: linkedinCookies });
await commands['linkedin/job-detail'].func(page, { 'job-url': 'https://www.linkedin.com/jobs/view/123/' }); Defensive patterns
Strategy: try-catch
Validate before calling
if (typeof page === 'undefined' || !page) {
throw new Error('Start a browser session (valid LinkedIn cookies required) before running linkedin job-detail');
}
if (!/^https:\/\/www\.linkedin\.com\/jobs\/view\/\d+\/?/.test(jobUrl)) {
throw new Error('job-url must be a LinkedIn job view URL');
} Type guard
function hasBrowserPage(page) {
return typeof page === 'object' && page !== null && typeof page.goto === 'function' && typeof page.evaluate === 'function';
} Try / catch
try {
const rows = await runCli(['linkedin', 'job-detail', jobUrl]);
} catch (err) {
if (String(err.message).includes('Browser session required')) {
await startBrowserSession({ cookies: loadLinkedInCookies() });
// retry once
} else throw err;
} Prevention
- Always launch the command through the CLI entry so browser:true starts a session
- Keep LinkedIn cookies fresh; re-login before long-running jobs
- Install/verify Chromium availability in CI before running browser commands
- When calling func directly, always pass a page stub with goto/wait/evaluate
When it happens
Trigger: Calling the job-detail command's func with page === null/undefined — e.g. running the CLI without an active browser session, a failed COOKIE-strategy login leaving no page, or invoking func programmatically without a page argument.
Common situations: Expired or missing LinkedIn cookies so the browser session never starts; running the command in a headless environment where browser launch failed; calling the exported func directly in tests without a mocked page; CI containers lacking Chromium.
Related errors
- Browser session required for linkedin jobs-preferences
- LinkedIn sent-invitations verification requires an active si
- LinkedIn requires an active signed-in browser session.
- Browser session required for linkedin people-search
- Browser session required for linkedin salesnav-search
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/7fa52ae5a205c39b.
Report an issue: GitHub.