jackwener/OpenCLI · warning · AuthRequiredError
Waiting for Toutiao sessionid cookie
Error message
Waiting for Toutiao sessionid cookie
What it means
AuthRequiredError thrown by the toutiao site-auth poll handler on each poll tick while waiting for the user to finish login: if the sessionid cookie is not yet present, the poll throws instead of returning an identity. It signals 'login not finished yet' during the interactive polling loop, not a hard failure.
Source
Thrown at clis/toutiao/auth.js:66
}
return { ok: true, user_id: userId, nickname };
})()
`);
if (probe?.kind === 'auth') throw new AuthRequiredError('toutiao.com', probe.detail);
if (!probe?.ok) throw new CommandExecutionError(`Unexpected Toutiao probe: ${JSON.stringify(probe)}`);
return { user_id: probe.user_id, nickname: probe.nickname };
}
registerSiteAuthCommands({
site: 'toutiao',
domain: 'toutiao.com',
loginUrl: 'https://mp.toutiao.com/auth/page/login',
columns: ['user_id', 'nickname'],
quickCheck: hasToutiaoSessionCookie,
verify: verifyToutiaoIdentity,
poll: async (page) => {
if (!await hasToutiaoSessionCookie(page)) {
throw new AuthRequiredError('toutiao.com', 'Waiting for Toutiao sessionid cookie');
}
return verifyToutiaoIdentity(page);
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Complete the login at https://mp.toutiao.com/auth/page/login in the browser window before the poll window expires; the next poll then succeeds.
- If the poll loop aborts on this throw, restart toutiao auth login and finish login promptly.
- Handle AuthRequiredError in your polling wrapper and keep polling until a deadline instead of aborting on the first throw.
- Clear any CAPTCHA/interstitials quickly, or log in manually beforehand in the same profile so the cookie already exists.
- Increase the poll timeout/deadline if your login path (2FA, SMS, QR) routinely exceeds it.
Example fix
// before: caller aborts on the first poll throw
await pollUntil(() => authPoll(page), timeout);
// after: tolerate 'waiting' during login
await pollUntil(async () => {
try {
return await authPoll(page);
} catch (e) {
if (e.name === 'AuthRequiredError' && /Waiting for/.test(e.message)) return false;
throw e;
}
}, timeout); Defensive patterns
Strategy: retry
Validate before calling
// Caller-side preflight before starting the login poll
const deadline = Date.now() + 120_000;
const hasSession = async () =>
(await page.getCookies({ url: 'https://mp.toutiao.com' }))
.some(c => c.name === 'sessionid' && c.value);
if (!(await hasSession()) && Date.now() > deadline) {
throw new Error('Login window expired without a sessionid cookie');
} Type guard
function isWaitingForLoginError(err) {
return !!err && err.name === 'AuthRequiredError' && /Waiting for Toutiao sessionid cookie/.test(err.message);
} Try / catch
try {
await toutiaoAuthLogin(page);
} catch (err) {
if (isWaitingForLoginError(err)) {
// keep polling until the deadline instead of aborting
console.warn('Login not finished yet — retrying poll...');
} else {
throw err;
}
} Prevention
- Complete the browser login (including 2FA/CAPTCHA) promptly once the login window opens.
- Set a poll deadline and keep polling on this specific error rather than aborting the flow.
- Log in manually beforehand in the same persistent profile so the sessionid cookie already exists.
- Don't close the login tab or browser window while the poll loop is running.
- Allow extra time for QR-code/SMS login paths which routinely exceed short poll timeouts.
When it happens
Trigger: During the toutiao auth login/poll flow, a poll iteration runs before login completes — getCookies for https://mp.toutiao.com still has no non-empty sessionid cookie.
Common situations: User is slow entering credentials/2FA in the opened login window; a CAPTCHA or QR-code scan is pending; the user closed the login tab without logging in; the poll window is too short for the chosen login method.
Related errors
- Waiting for Jike login: ${detail}
- Waiting for Jimeng login
- Waiting for Ke lianjia_token cookie
- Waiting for Kimi auth cookies
- linkedin.com: Waiting for LinkedIn li_at cookie
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/6f872deb41dbe772.
Report an issue: GitHub.