jackwener/OpenCLI · error · CommandExecutionError

subreddit-info failed: ${result.detail}

Error message

subreddit-info failed: ${result.detail}

What it means

CommandExecutionError thrown when the page.evaluate IIFE that fetches /r/<name>/about.json itself throws an exception inside the browser (e.g. JSON.parse failure, network error, CSP block). The browser-side error is caught, wrapped as {kind:'exception', detail}, and re-thrown on the Node side prefixed with 'subreddit-info failed:'.

Source

Thrown at clis/reddit/subreddit-info.js:86

          return { kind: 'malformed', detail: 'Reddit returned malformed subreddit info for r/' + sub + ' (missing data.display_name).' };
        }
        return { kind: 'ok', info };
      } catch (e) {
        return { kind: 'exception', detail: String(e && e.message || e) };
      }
    })()`);

        if (result?.kind === 'missing') {
            throw new EmptyResultError(result.detail);
        }
        if (result?.kind === 'http') {
            throw new CommandExecutionError(`HTTP ${result.httpStatus} from ${result.where}`);
        }
        if (result?.kind === 'malformed') {
            throw new CommandExecutionError(result.detail);
        }
        if (result?.kind === 'exception') {
            throw new CommandExecutionError(`subreddit-info failed: ${result.detail}`);
        }
        if (result?.kind !== 'ok') {
            throw new CommandExecutionError(`Unexpected result from reddit subreddit-info: ${JSON.stringify(result)}`);
        }

        const s = result.info;
        const created = s.created_utc
            ? new Date(s.created_utc * 1000).toISOString().split('T')[0]
            : null;
        const subscribers = typeof s.subscribers === 'number' ? s.subscribers : null;
        const activeNow = typeof s.active_user_count === 'number'
            ? s.active_user_count
            : (typeof s.accounts_active === 'number' ? s.accounts_active : null);
        const description = typeof s.public_description === 'string'
            ? s.public_description.trim()
            : '';

        return [

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Read the detail after the prefix to see the underlying browser error message
  2. Check whether an extension (ad-blocker, privacy tool) is blocking reddit.com fetches and disable it for reddit.com
  3. Verify the browser session has real internet connectivity (no captive portal/proxy injecting HTML)
  4. Retry — transient network failures often clear on a second run
  5. Update the CLI/library if the error persists across environments, as the evaluate harness may need a fix
Defensive patterns

Strategy: try-catch

Validate before calling

// preflight: confirm the browser can reach reddit.com
await page.goto('https://www.reddit.com', { waitUntil: 'domcontentloaded' });

Type guard

function isSubredditInfoFailure(e){ return e instanceof Error && e.message.startsWith('subreddit-info failed: '); }

Try / catch

try { await cli.redditSubredditInfo(name); }
catch (e) {
  if (e.message.startsWith('subreddit-info failed: ')) {
    console.warn('browser-side error:', e.message);
    return retryWithBackoff(() => cli.redditSubredditInfo(name));
  }
  throw e;
}

Prevention

When it happens

Trigger: Browser-side fetch rejects (network failure, blocked request, CSP), res.json() throws on non-JSON HTML bodies, or any other runtime error inside the evaluated async function.

Common situations: Browser extensions or ad-blockers blocking reddit.com API paths; the page navigating away mid-evaluate; a captive portal / proxy injecting HTML so res.json() throws 'Unexpected token <'; intermittent network drops.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/34a7291b37a0506e. Report an issue: GitHub.