jackwener/OpenCLI · error · CommandExecutionError
${result.error}
Error message
${result.error} What it means
This is the non-auth branch of the same check in `reddit saved`: when the in-page script returned an error and it does not include 'Not logged in', the raw error string is re-thrown as a CommandExecutionError (error 3376 prefixes it; this entry is the direct rethrow at the adjacent line). Both represent a generic in-page failure while fetching the saved list; only authentication problems are routed to AuthRequiredError.
Source
Thrown at clis/reddit/saved.js:46
const res = await fetch('/user/' + username + '/saved.json?limit=' + limit + '&raw_json=1', {
credentials: 'include'
});
const d = await res.json();
return (d?.data?.children || []).map(c => ({
title: c.data.title || c.data.body?.slice(0, 100) || '',
subreddit: c.data.subreddit_name_prefixed || 'r/' + (c.data.subreddit || '?'),
score: c.data.score || 0,
comments: c.data.num_comments || 0,
url: 'https://www.reddit.com' + (c.data.permalink || ''),
}));
} catch (e) {
return { error: e.toString() };
}
})()`);
if (result?.error) {
if (String(result.error).includes('Not logged in'))
throw new AuthRequiredError('reddit.com', result.error);
throw new CommandExecutionError(result.error);
}
return (result || []).slice(0, kwargs.limit);
}
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Read the thrown error string to identify the underlying in-page failure
- Re-login to refresh the session, then retry the saved command
- Reinstall/update the package in case your injected script is out of sync with Reddit's current page
- Retry after a short backoff for transient failures
Example fix
// before
const saved = await runCli(['reddit', 'saved']);
// after
try {
const saved = await runCli(['reddit', 'saved']);
} catch (e) {
console.error('saved list failed:', e.message); // inspect and retry once
} Defensive patterns
Strategy: try-catch
Validate before calling
// Validate session validity before invoking:
const ok = await page.evaluate("fetch('/api/me.json?raw_json=1',{credentials:'include'}).then(r=>r.ok)");
if (!ok) throw new Error('Session invalid — re-login before listing saved posts'); Type guard
function isInPageError(r) {
return r != null && typeof r === 'object' && typeof r.error === 'string';
} Try / catch
try {
const saved = await runCli(['reddit', 'saved']);
} catch (e) {
if (e instanceof CommandExecutionError && !/Not logged in/.test(e.message)) {
console.error('In-page failure:', e.message);
await sleep(2000); // single retry for transient issues
} else throw e;
} Prevention
- Log the raw error string — it is the in-page exception text
- Re-login after any session refresh or long idle period
- Keep the injected script current with Reddit's page structure
When it happens
Trigger: page.evaluate catch block returns { error: e.toString() } for anything other than login issues: TypeError from missing DOM nodes, failed fetch, JSON.parse failure on an unexpected Reddit response.
Common situations: Reddit A/B tests changing page structure; temporary 5xx served to the in-page fetch; script bugs after partial edits to the injected code.
Related errors
- reddit.com: ${result.error}
- Not a git repository
- Working tree not clean: ${status}
- 1point3acres thread
- 1point3acres user
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/cfa35e3bcf45bab9.
Report an issue: GitHub.