jackwener/OpenCLI · warning · AuthRequiredError
Waiting for Pixiv PHPSESSID cookie
Error message
Waiting for Pixiv PHPSESSID cookie
What it means
This AuthRequiredError is thrown by the pixiv auth poll handler in clis/pixiv/auth.js:60 while waiting for the user to complete the browser login flow. Pixiv only sets a logged-in PHPSESSID cookie whose value is '<numericUserId>_<hash>'; an anonymous session has a bare hash. The poll checks for a cookie matching /^\d+_/ on https://www.pixiv.net, and throws until the user finishes signing in, so the CLI can keep polling instead of proceeding unauthenticated.
Source
Thrown at clis/pixiv/auth.js:60
}
})()`);
if (probe?.kind === 'auth') throw new AuthRequiredError('pixiv.net', probe.detail);
if (probe?.kind === 'http') throw new CommandExecutionError(`HTTP ${probe.httpStatus} from Pixiv ajax`);
if (probe?.kind === 'exception') throw new CommandExecutionError(`Pixiv whoami failed: ${probe.detail}`);
if (!probe?.ok) throw new CommandExecutionError(`Unexpected Pixiv probe: ${JSON.stringify(probe)}`);
return { user_id: probe.user_id, name: probe.name };
}
registerSiteAuthCommands({
site: 'pixiv',
domain: 'pixiv.net',
loginUrl: 'https://accounts.pixiv.net/login',
columns: ['user_id', 'name'],
quickCheck: hasPixivSessionCookie,
verify: verifyPixivIdentity,
poll: async (page) => {
if (!await hasPixivSessionCookie(page)) {
throw new AuthRequiredError('pixiv.net', 'Waiting for Pixiv PHPSESSID cookie');
}
return verifyPixivIdentity(page);
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Complete the login in the opened browser window at https://accounts.pixiv.net/login with your Pixiv credentials
- Wait and let the poll retry — the error clears once a logged-in PHPSESSID (<uid>_<hash>) is set
- Clear cookies for pixiv.net and restart the auth flow if you logged in but still see this (stale anonymous session)
- Check the browser profile is not blocking or discarding cookies for accounts.pixiv.net and www.pixiv.net
- Re-run the pixiv auth command if your session expired
Defensive patterns
Strategy: try-catch
Validate before calling
const cookies = await page.getCookies({ url: 'https://www.pixiv.net' });
const loggedIn = cookies.some(c => c.name === 'PHPSESSID' && /^\d+_/.test(c.value || ''));
if (!loggedIn) {
console.log('Open the browser and finish the Pixiv login before continuing.');
} Type guard
function hasPixivSession(cookies) {
return Array.isArray(cookies) && cookies.some(
c => c && c.name === 'PHPSESSID' && /^\d+_[A-Za-z0-9]+$/.test(String(c.value || ''))
);
} Try / catch
try {
await poll(page);
} catch (e) {
if (e instanceof AuthRequiredError && e.message.includes('PHPSESSID')) {
// Prompt the user to complete login in the browser, then retry after a delay
await promptLoginAndDelay();
} else {
throw e;
}
} Prevention
- Complete the login form promptly in the browser window the CLI opens
- Verify cookies are enabled and not cleared for accounts.pixiv.net / www.pixiv.net
- If login appears done but polling still fails, clear pixiv.net cookies and restart the auth flow
- Check the session has not expired before running batch jobs
When it happens
Trigger: Running the pixiv login/auth command: the poll callback fires, page.getCookies({url:'https://www.pixiv.net'}) returns cookies, but no PHPSESSID exists or its value lacks the numeric uid prefix (anonymous session) at clis/pixiv/auth.js:59.
Common situations: User has not yet completed the login form at accounts.pixiv.net; user logged in but Pixiv served an anonymous PHPSESSID (not actually signed in); cookies blocked or cleared mid-flow; login expired so only the bare-hash anonymous PHPSESSID is present; automation raced ahead of the browser navigation.
Related errors
- Pixiv PHPSESSID cookie missing
- Pixiv PHPSESSID prefix unparseable
- Waiting for Toutiao sessionid cookie
- Waiting for Ctrip login_uid cookie
- Waiting for Doubao login
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/a20046d118128e69.
Report an issue: GitHub.