DIYgod/RSSHub · error · RenewWeiboCookiesError
Cookies expired. Msg: ${resp?.data?.msg || ''} ${resp?.data?
Error message
Cookies expired. Msg: ${resp?.data?.msg || ''} ${resp?.data?.url || ''} What it means
A RenewWeiboCookiesError raised by the response verifier whenever a weibo API call returns data.ok === -100, weibo's signal that the active cookies (cached visitor cookies or user-supplied WEIBO_COOKIES) are no longer valid. The msg/url from the response body are appended for diagnostics.
Source
Thrown at lib/routes/weibo/utils.ts:126
if (times < 2 || !cookies) {
throw new Error(`Unable to fetch visitor cookies. Please set WEIBO_COOKIES. Redirection: ${times}, last URL: ${page.url()}`);
}
return cookies;
})();
try {
return await visitorCookiesPromise;
} finally {
visitorCookiesPromise = undefined;
}
});
};
})(),
tryWithCookies: (() => {
let errors = 0;
const verifier = (resp: any): void => {
if (resp?.data?.ok === -100) {
throw new RenewWeiboCookiesError(`Cookies expired. Msg: ${resp?.data?.msg || ''} ${resp?.data?.url || ''}`);
}
};
return async <T>(callback: (cookies: string, verifier: (resp: any) => void) => Promise<T>): Promise<T> => {
try {
return await callback(await weiboUtils.getCookies(false), verifier);
} catch (error: any) {
if (error.message?.includes('WEIBO_COOKIES')) {
throw error;
}
if (errors > 10) {
logger.warn(`Too many errors while fetching data from weibo API, renewing Cookies: ${error.message}`);
logger.info('Please open an issue on GitHub if renewing Cookies fixes the error');
} else if ((error.name === 'HTTPError' || error.name === 'FetchError') && error.status === 432) {
// empty
} else if (error.name === 'RenewWeiboCookiesError') {
// empty
} else {
errors++;View on GitHub (pinned to bed535e087)
Solutions
- If WEIBO_COOKIES is set, refresh it from a browser session (this error usually precedes error 620 when pinned cookies are used).
- If relying on auto visitor cookies, confirm Playwright works (error 622) so the auto-renew triggered by this error can succeed.
- Inspect the appended msg/url in the log to distinguish true expiry from a transient weibo-side error.
Defensive patterns
Strategy: retry
Validate before calling
// Inspect a sample API response before trusting the cookie path
const probe = await got('https://m.weibo.cn/feed/friends?max_id=0', { headers: { ...weiboUtils.apiHeaders, Cookie: cookies } });
if (probe.data?.ok === -100) {
throw new Error('Weibo reports ok=-100 — cookies are already expired; do not proceed.');
} Type guard
function isRenewWeiboCookiesError(e: unknown): boolean {
return e instanceof Error && (e.name === 'RenewWeiboCookiesError' || /Cookies expired\. Msg:/i.test(e.message));
} Try / catch
// tryWithCookies already handles one renew; at the caller, allow a bounded second attempt
try {
return await weiboUtils.tryWithCookies(cb);
} catch (e) {
if (isRenewWeiboCookiesError(e)) {
// one renew already happened internally and failed; surface rather than loop
throw e;
}
throw e;
} Prevention
- Wrap every weibo API call with the provided verifier so ok=-100 is caught uniformly.
- Alert on RenewWeiboCookiesError frequency — a spike means cookies/IP are being invalidated.
- Don't catch and swallow this error; let tryWithCookies drive the renew, then fail loudly if it persists.
When it happens
Trigger: verifier(resp) sees resp.data.ok === -100 on any weibo API response passed through tryWithCookies' callback, throwing at utils.ts:126. tryWithCookies then catches it and triggers a cookie renew.
Common situations: Cookies expired server-side; weibo invalidated the session (logout, security reset); visitor cookies were blacklisted; rate-limited into a soft-expiry state.
Related errors
- Weibo Friends Timeline is not available due to the absense o
- Weibo Group Timeline is not available due to the absense of
- Weibo user bookmarks is not available due to the absense of
- Cookies expired. Please update WEIBO_COOKIES
- ${tagResponse.msg}
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/c2967ce45b64de13.
Report an issue: GitHub.