jackwener/OpenCLI · error · CommandExecutionError
Browser session required
Error message
Browser session required
What it means
Thrown by ensurePage when the browser page reference is null/undefined — i.e. no active browser session page exists to run the Instagram metadata fetch in. Callers must establish a browser page before invoking Instagram metadata operations.
Source
Thrown at clis/instagram/download.js:298
const picked = pickNode(nodes[index], index);
if (!picked.ok) {
return { ok: false, errorCode: 'COMMAND_EXEC', error: picked.error };
}
items.push(picked.item);
}
return {
ok: true,
shortcode: media.code,
owner: media?.user?.username || '',
items,
};
})()
`;
}
function ensurePage(page) {
if (!page)
throw new CommandExecutionError('Browser session required');
return page;
}
function normalizeFetchResult(result) {
const unwrapped = unwrapEvaluateResult(result);
if (!unwrapped || typeof unwrapped !== 'object' || Array.isArray(unwrapped)) {
throw new CommandExecutionError('Failed to fetch Instagram media metadata');
}
if (typeof unwrapped.ok !== 'boolean') {
throw new CommandExecutionError('Instagram media metadata returned malformed result');
}
return unwrapped;
}
function handleFetchFailure(result) {
const message = result.error || 'Instagram media fetch failed';
if (result.errorCode === 'AUTH_REQUIRED') {
throw new AuthRequiredError('instagram.com', message);
}
if (result.errorCode === 'RATE_LIMITED') {View on GitHub (pinned to 49907e53dc)
Solutions
- Ensure the browser session is started and a page is created before downloading
- Check browser launch errors earlier in the flow (missing browser, bad profile path)
- Re-run the command so a fresh page is established
Example fix
// before const page = maybeGetPage(); // undefined await download(page); // after const page = await launchBrowserAndGetPage(); if (!page) throw ...; // or ensure the flow guarantees a page await download(page);
Defensive patterns
Strategy: try-catch
Validate before calling
const page = await browser.newPage();
if (!page) throw new Error('Browser page could not be created before download'); Type guard
function hasPage(p) {
return !!p && typeof p.evaluate === 'function';
} Try / catch
try {
await igDownload(url);
} catch (e) {
if (e.message === 'Browser session required') {
console.error('Initialize/relaunch the browser session before downloading.');
} else throw e;
} Prevention
- Always launch the browser and create a page before calling download flows
- Check for launch failures (missing browser binary, bad profile) early
- Verify page lifetime — don't close the page before the download completes
When it happens
Trigger: Calling browserPage-driven download flow when browser launch or page creation failed/was skipped, so page is falsy when ensurePage is called.
Common situations: Browser failed to launch (missing browser binary), session teardown ran before download, or code path invoked without initializing the browser session.
Related errors
- ChatGPT did not create a conversation URL after sending the
- Grok composer rejected the prompt: ${JSON.stringify(sendResu
- ${before.reason || `Failed to inspect ${name} state.`}${deta
- Unexpected Manus probe: ${JSON.stringify(probe)}
- Midjourney Imagine composer was not found.
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/7a88cee033c43865.
Report an issue: GitHub.