jackwener/OpenCLI · error · CommandExecutionError
Maimai whoami failed: ${probe.detail}
Error message
Maimai whoami failed: ${probe.detail} What it means
Thrown at clis/maimai/auth.js:35 when the WHOAMI_PROBE's internal try/catch caught a JavaScript exception in the page and returned kind:'exception'. The message embeds the browser-side error (probe.detail). It means the login-verification script itself crashed while scanning page scripts or parsing userObj — not that you're logged out.
Source
Thrown at clis/maimai/auth.js:35
if (!user || !user.id) return { kind: 'auth', detail: 'Maimai userObj missing from page (anonymous)' };
return {
ok: true,
user_id: String(user.id),
name: String(user.name || ''),
company: String(user.company || ''),
};
} catch (e) {
return { kind: 'exception', detail: String(e && e.message || e) };
}
})()`;
async function verifyMaimaiIdentity(page) {
await page.goto('https://maimai.cn/');
await page.wait(2);
const probe = await page.evaluate(WHOAMI_PROBE);
if (probe?.kind === 'auth') throw new AuthRequiredError('maimai.cn', probe.detail);
if (probe?.kind === 'http') throw new CommandExecutionError(`HTTP ${probe.httpStatus} from Maimai`);
if (probe?.kind === 'exception') throw new CommandExecutionError(`Maimai whoami failed: ${probe.detail}`);
if (!probe?.ok) throw new CommandExecutionError(`Unexpected Maimai probe: ${JSON.stringify(probe)}`);
return { user_id: probe.user_id, name: probe.name, company: probe.company };
}
registerSiteAuthCommands({
site: 'maimai',
domain: 'maimai.cn',
loginUrl: 'https://maimai.cn/',
columns: ['user_id', 'name', 'company'],
verify: verifyMaimaiIdentity,
poll: verifyMaimaiIdentity,
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Re-run the check — transient navigation/redirect races often resolve on retry
- Open maimai.cn manually and confirm the page renders normally
- Increase the wait after page.goto so redirects settle before probing
- If maimai changed the userObj script format, update the WHOAMI_PROBE regex
- Check for interfering browser extensions or run a clean profile
Example fix
// before
await page.goto('https://maimai.cn/');
await page.wait(2);
const probe = await page.evaluate(WHOAMI_PROBE);
// after
await page.goto('https://maimai.cn/', { waitUntil: 'networkidle' });
await page.wait(5); // let redirects/spa routing settle before probing
const probe = await page.evaluate(WHOAMI_PROBE); Defensive patterns
Strategy: retry
Validate before calling
// ensure the page is on maimai.cn and settled before probing
if (!page.url().includes('maimai.cn')) await page.goto('https://maimai.cn/');
await page.wait(3); Type guard
function isProbeException(e) {
return e instanceof Error && e.message.startsWith('Maimai whoami failed:');
} Try / catch
try {
await verifyMaimaiIdentity(page);
} catch (e) {
if (isProbeException(e)) {
await page.reload();
await page.wait(5);
return verifyMaimaiIdentity(page); // single retry
}
throw e;
} Prevention
- Reload and re-probe once before giving up — redirect races are common
- Wait for page stability (networkidle) before page.evaluate
- Test in a clean browser profile without extensions
- Keep WHOAMI_PROBE in sync with maimai's inline-script format
When it happens
Trigger: page.evaluate throwing inside the probe: DOM APIs unavailable, scripts enumeration failing, JSON.parse hitting malformed content that escapes the inner try, or the page context being destroyed by a redirect/navigation during the 2s wait.
Common situations: Maimai homepage redirects mid-probe (SPA navigation destroying context); browser extension injecting scripts that break enumeration; maimai.cn changing its inline-script format so parsing throws; headless browser quirks.
Related errors
- ${label}: ${String(payload.error)}
- ${label} returned malformed extraction payload
- coupang add-to-cart evaluation failed: ${error?.message || e
- Douyin search: unexpected evaluator payload shape
- Jimeng whoami failed: ${probe.detail}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/6e477b4c3fec8dbc.
Report an issue: GitHub.