{"record":{"id":"89c3db6065082bcc","repo":"DIYgod/RSSHub","slug":"cookies-expired-please-update-weibo-cookies","errorCode":null,"errorMessage":"Cookies expired. Please update WEIBO_COOKIES","messagePattern":"Cookies expired\\. Please update WEIBO_COOKIES","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/routes/weibo/utils.ts","lineNumber":55,"sourceCode":"};\n\nconst weiboUtils = {\n    apiHeaders: {\n        'MWeibo-Pwa': 1,\n        'X-Requested-With': 'XMLHttpRequest',\n        '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',\n    },\n    RenewWeiboCookiesError,\n    getCookies: (() => {\n        const url = 'https://m.weibo.cn/';\n        const coolingDownMessage = `Cooling down before new visitor Cookies from ${url} may be fetched`;\n        let coolingDown = false;\n        let visitorCookiesPromise: Promise<string> | undefined;\n\n        return async (renew: any = false) => {\n            if (config.weibo.cookies) {\n                if (renew) {\n                    throw new Error('Cookies expired. Please update WEIBO_COOKIES');\n                }\n                return config.weibo.cookies;\n            }\n\n            const cacheKey = 'weibo:visitor-cookies';\n            if (renew) {\n                cache.set(cacheKey, '', 1);\n            }\n            return await cache.tryGet(cacheKey, async () => {\n                if (visitorCookiesPromise) {\n                    return await visitorCookiesPromise;\n                }\n                if (coolingDown) {\n                    if (renew?.message) {\n                        logger.warn(coolingDownMessage);\n                        throw renew;\n                    }\n                    throw new Error(coolingDownMessage);","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/weibo/utils.ts#L37-L73","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before (env)\nWEIBO_COOKIES=SUB=_2A25...; SUBP=...   // stale\n// after\nWEIBO_COOKIES=SUB=_2A25<new>...; SUBP=<new>...   // refreshed from browser DevTools","handlingStrategy":"validation","validationCode":"// Before relying on pinned weibo cookies, sanity-check they are present and non-empty\nif (process.env.WEIBO_COOKIES != null && process.env.WEIBO_COOKIES.trim() === '') {\n    throw new Error('WEIBO_COOKIES is set but empty — weibo will report it as expired.');\n}","typeGuard":"function isWeiboCookieExpiryError(e: unknown): boolean {\n    return e instanceof Error && /update WEIBO_COOKIES/i.test(e.message);\n}","tryCatchPattern":"try {\n    return await weiboUtils.tryWithCookies((cookies, verify) => fetchWeibo(cookies, verify));\n} catch (e) {\n    if (isWeiboCookieExpiryError(e)) {\n        // surface to operator; do NOT auto-retry — pinned cookies need manual rotation\n        monitoring.alert('weibo cookies expired', e);\n    }\n    throw e;\n}","preventionTips":["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."],"tags":["weibo","cookies","config","authentication"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}