jackwener/OpenCLI · error · CommandExecutionError
rednote notifications: unexpected evaluate response
Error message
rednote notifications: unexpected evaluate response
What it means
After loading the rednote notifications page, the command evaluates an in-page script and expects an object back. If page.evaluate returns null, undefined, or a primitive, it throws CommandExecutionError because the extraction script's contract was violated. This usually indicates the script failed to run or the page context was replaced.
Source
Thrown at clis/rednote/notifications.js:130
navigateBefore: false,
args: [
{
name: 'type',
default: 'mentions',
help: 'Notification type: mentions, likes, or connections',
},
{ name: 'limit', type: 'int', default: 20, help: 'Number of notifications to return' },
],
columns: ['rank', 'user', 'action', 'content', 'note', 'time'],
func: async (page, kwargs) => {
const type = parseNotificationType(kwargs.type);
const limit = parseLimit(kwargs.limit);
await page.goto('https://www.rednote.com/notification');
await page.wait({ time: 2 });
const script = READ_NOTIFICATIONS_JS.replace(JSON.stringify('PLACEHOLDER_TYPE'), JSON.stringify(type));
const data = await page.evaluate(script);
if (!data || typeof data !== 'object') {
throw new CommandExecutionError('rednote notifications: unexpected evaluate response');
}
if (data.error) {
throw new CommandExecutionError(`rednote notifications: ${data.error}${data.detail ? ' (' + data.detail + ')' : ''}`, 'The rednote SPA may still be hydrating; reload www.rednote.com/notification and retry.');
}
return (data.items || [])
.slice(0, limit)
.map((row, i) => ({ rank: i + 1, ...row }));
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Retry the command after reloading https://www.rednote.com/notification
- Catch this error and fall back to a full page reload with a longer wait before evaluate
- Inspect whether the page is behind a login/interstitial and authenticate first
- Check driver versions for evaluate() result-serialization changes
Example fix
// before
const data = await page.evaluate(script);
// after
let data;
try { data = await page.evaluate(script); } catch (e) { data = null; }
if (!data || typeof data !== 'object') {
await page.reload(); await page.wait({ time: 3 });
data = await page.evaluate(script);
} Defensive patterns
Strategy: try-catch
Validate before calling
const data = await page.evaluate(script); const ok = data !== null && typeof data === 'object' && !Array.isArray(data);
Type guard
const isEvaluateObject = (v) => v !== null && typeof v === 'object';
Try / catch
try { return await fetchNotifications(page, type, limit); } catch (e) { if (e instanceof CommandExecutionError && /unexpected evaluate response/.test(e.message)) { await page.reload(); await page.wait({ time: 3 }); return fetchNotifications(page, type, limit); } throw e; } Prevention
- Reload and re-wait before retrying evaluate on SPA pages
- Verify the page is not redirecting (login/interstitial) before extraction
- Pin and test against your browser driver's evaluate serialization behavior
When it happens
Trigger: page.evaluate(script) resolving to a non-object: the injected READ_NOTIFICATIONS_JS threw and returned undefined, the SPA navigated/clobbered the document mid-evaluation, or the browser driver returned a serialized non-object value.
Common situations: Page redirecting to login or an interstitial between goto and evaluate, slow network leaving the SPA in a broken state, driver/version returning values in an unexpected wrapper, or anti-bot script aborting injected code.
Related errors
- rednote notifications: ${data.error}${data.detail ? ' (' + d
- Unexpected Rednote search extraction payload shape; expected
- Failed to read ${draftType} drafts
- ${webHost} feed: unexpected evaluate response
- ${webHost} feed: ${data.error}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/a9094057d9f79999.
Report an issue: GitHub.