{"record":{"id":"8fee615cb07ae10f","repo":"jackwener/OpenCLI","slug":"browser-session-required-8fee61","errorCode":null,"errorMessage":"Browser session required","messagePattern":"Browser session required","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/reddit/subscribed.js","lineNumber":70,"sourceCode":"    };\n}\n\ncli({\n    site: 'reddit',\n    name: 'subscribed',\n    description: 'List subreddits you are subscribed to',\n    access: 'read',\n    domain: 'reddit.com',\n    strategy: Strategy.COOKIE,\n    browser: true,\n    args: [\n        { name: 'limit', type: 'int', default: 100, help: `Max subreddits to return (1-${REDDIT_SUBSCRIBED_MAX_LIMIT}, auto-paginates)` },\n    ],\n    columns: ['id', 'subreddit', 'title', 'subscribers', 'description', 'url'],\n    func: async (page, kwargs) => {\n        const limit = parseRedditSubscribedLimit(kwargs.limit);\n        if (!page)\n            throw new CommandExecutionError('Browser session required');\n        await page.goto('https://www.reddit.com');\n        const result = unwrapEvaluateResult(await page.evaluate(`(async () => {\n      ${BROWSER_JSON_SNIFF_FN}\n      try {\n        // fetchJsonOrLoginWall sniffs HTML responses (login wall / WAF / rate-limit\n        // page) and returns a structured { __loginWall, status, url, ... } sentinel\n        // instead of letting JSON.parse blow up with \"Unexpected token '<'\".\n        const me = await fetchJsonOrLoginWall('/api/me.json?raw_json=1', { credentials: 'include' });\n        if (me && me.__loginWall) {\n          return { kind: 'login-wall', sentinel: me, where: '/api/me.json' };\n        }\n        if (me && me.error === 401 || me && me.error === 403) {\n          return { kind: 'auth', detail: 'Reddit /api/me.json returned HTTP ' + me.error };\n        }\n        if (me && me.error) {\n          return { kind: 'http', httpStatus: me.error, where: '/api/me.json' };\n        }\n        const username = me?.data?.name || me?.name;","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/reddit/subscribed.js#L52-L88","documentation":"CommandExecutionError thrown when the reddit subscribed command runs without an active browser session. The command fetches /api/me.json and /subreddits/mine/subscriptions.json with cookie credentials inside the browser, so a page handle is mandatory; without one the command fails before any network call.","triggerScenarios":"Invoking the subscribed command where the browser-backed `page` is null/undefined — no browser launched, headless environment without a browser, or calling the command function programmatically with page=null.","commonSituations":"Running the CLI in CI/containers without a browser; failing browser launch upstream; embedding the library and not supplying a page; forgetting to enable browser mode for this browser:true command.","solutions":["Run the command in the library's browser mode so a page session is created before func executes","Ensure a Chromium/Playwright-compatible browser is installed and launchable in your environment","Log into reddit.com in that browser session — listing subscriptions requires authenticated cookies","If embedding, pass a real page object (not null) when calling the command function"],"exampleFix":"// before\nawait redditSubscribed(null, { limit: 100 }) // throws\n// after\nconst page = await browser.newPage();\nawait loginReddit(page);\nawait redditSubscribed(page, { limit: 100 });","handlingStrategy":"validation","validationCode":"if (!page || typeof page.goto !== 'function') throw new Error('subscribed requires an active browser page');","typeGuard":"function hasBrowserPage(p){ return !!p && typeof p.goto === 'function' && typeof p.evaluate === 'function'; }","tryCatchPattern":"try { const rows = await cli.redditSubscribed({ limit }); }\ncatch (e) { if (e.message === 'Browser session required') { const page = await launchBrowserAndLogin(); return cli.redditSubscribed({ limit }, { page }); } throw e; }","preventionTips":["Run browser:true commands only in environments where the library can launch a browser","Verify browser availability in CI before invoking","Keep an authenticated reddit.com session in the browser profile — subscriptions require cookies","When embedding, always supply a live page object rather than null"],"tags":["reddit","browser-session","authentication"],"backgroundTag":"browser-session-required","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}