DIYgod/RSSHub · error · Error
Cookies expired. Please update WEIBO_COOKIES
Error message
Cookies expired. Please update WEIBO_COOKIES
What it means
Thrown by weibo getCookies() when the operator has pinned cookies via the WEIBO_COOKIES env var AND a renew was requested (the verifier saw an expired-cookie signal or too many API errors). Because user-supplied cookies are pinned, the auto visitor-cookie refresh path cannot run, so RSSHub surfaces this to force a manual cookie rotation.
Source
Thrown at lib/routes/weibo/utils.ts:55
};
const weiboUtils = {
apiHeaders: {
'MWeibo-Pwa': 1,
'X-Requested-With': 'XMLHttpRequest',
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1',
},
RenewWeiboCookiesError,
getCookies: (() => {
const url = 'https://m.weibo.cn/';
const coolingDownMessage = `Cooling down before new visitor Cookies from ${url} may be fetched`;
let coolingDown = false;
let visitorCookiesPromise: Promise<string> | undefined;
return async (renew: any = false) => {
if (config.weibo.cookies) {
if (renew) {
throw new Error('Cookies expired. Please update WEIBO_COOKIES');
}
return config.weibo.cookies;
}
const cacheKey = 'weibo:visitor-cookies';
if (renew) {
cache.set(cacheKey, '', 1);
}
return await cache.tryGet(cacheKey, async () => {
if (visitorCookiesPromise) {
return await visitorCookiesPromise;
}
if (coolingDown) {
if (renew?.message) {
logger.warn(coolingDownMessage);
throw renew;
}
throw new Error(coolingDownMessage);View on GitHub (pinned to bed535e087)
Solutions
- Re-open m.weibo.cn in a browser, copy the fresh Cookie header, and set WEIBO_COOKIES in the RSSHub env to the new value, then restart RSSHub.
- Temporarily unset WEIBO_COOKIES so RSSHub falls back to automatic visitor-cookie acquisition via Playwright.
- Check RSSHub logs for the preceding 'Cookies expired. Msg: ...' (error 623) to confirm the API-side expiry reason before rotating.
Example fix
// before (env) WEIBO_COOKIES=SUB=_2A25...; SUBP=... // stale // after WEIBO_COOKIES=SUB=_2A25<new>...; SUBP=<new>... // refreshed from browser DevTools
Defensive patterns
Strategy: validation
Validate before calling
// Before relying on pinned weibo cookies, sanity-check they are present and non-empty
if (process.env.WEIBO_COOKIES != null && process.env.WEIBO_COOKIES.trim() === '') {
throw new Error('WEIBO_COOKIES is set but empty — weibo will report it as expired.');
} Type guard
function isWeiboCookieExpiryError(e: unknown): boolean {
return e instanceof Error && /update WEIBO_COOKIES/i.test(e.message);
} Try / catch
try {
return await weiboUtils.tryWithCookies((cookies, verify) => fetchWeibo(cookies, verify));
} catch (e) {
if (isWeiboCookieExpiryError(e)) {
// surface to operator; do NOT auto-retry — pinned cookies need manual rotation
monitoring.alert('weibo cookies expired', e);
}
throw e;
} Prevention
- Treat WEIBO_COOKIES as a rotating secret with an owner and a refresh runbook.
- Monitor for error 623 (ok === -100) as the leading indicator before 620 surfaces.
- In CI/smoke tests, assert config.weibo.cookies is either unset (auto mode) or a recent value.
When it happens
Trigger: Called from tryWithCookies after a RenewWeiboCookiesError (API ok === -100) or after >10 generic API errors: it calls getCookies(error), and since config.weibo.cookies is truthy with a truthy renew arg, the renew branch throws at utils.ts:55.
Common situations: The WEIBO_COOKIES env value has aged out (weibo sessions expire), the account was logged out, or weibo rotated its cookie validation. Common after running the same WEIBO_COOKIES for weeks/months.
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. Msg: ${resp?.data?.msg || ''} ${resp?.data?
- BAIDU_COOKIE must contain BDUSS. Please check your cookie co
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/89c3db6065082bcc.
Report an issue: GitHub.