{"record":{"id":"f718a94f813f984b","repo":"DIYgod/RSSHub","slug":"http-error-status-res-status","errorCode":null,"errorMessage":"HTTP error! status: ${res.status}","messagePattern":"HTTP error! status: (.+?)","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/routes/iwara/subscriptions.ts","lineNumber":88,"sourceCode":"    const password = config.iwara.password;\n\n    const { page, destroy } = await getPlaywrightPage(rootUrl, {\n        gotoConfig: {\n            waitUntil: 'domcontentloaded',\n        },\n    });\n\n    try {\n        const fetchApi = (url: string, options: any) =>\n            page.evaluate(\n                async (args) => {\n                    const res = await fetch(args.url, {\n                        method: args.options.method || 'GET',\n                        headers: args.options.headers,\n                        body: args.options.body ? JSON.stringify(args.options.body) : undefined,\n                    });\n                    if (!res.ok) {\n                        throw new Error(`HTTP error! status: ${res.status}`);\n                    }\n                    return res.json();\n                },\n                { url, options }\n            );\n\n        // login and get refresh token\n        const refreshHeaders = await cache.tryGet(\n            'iwara:token',\n            async () => {\n                const result = await fetchApi(`${apiqRootUrl}/user/login`, {\n                    method: 'POST',\n                    headers: apiHeaders,\n                    body: { email: username, password },\n                });\n                return { authorization: 'Bearer ' + result.token };\n            },\n            30 * 24 * 60 * 60,","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/iwara/subscriptions.ts#L70-L106","documentation":"Thrown inside the Iwara subscriptions route's in-page `fetch` wrapper: it evaluates a `fetch(...)` call inside the Playwright page context and, if `res.ok` is false, throws `Error('HTTP error! status: <code>')`. This surfaces the HTTP status of the Iwara API call (login, user info, or subscriptions) as seen by the browser page. Common statuses: 401 (bad/expired credentials), 403 (blocked/forbidden), 429 (rate limit), 5xx (Iwara outage).","triggerScenarios":"Any Iwara API call made via the page-context fetch returns a non-2xx status: `${apiqRootUrl}/user/login` fails (401/403 on bad credentials), subsequent endpoints fail due to expired/invalid refresh token (cached under `iwara:token`), or Iwara rate-limits/blocks the server IP.","commonSituations":"Wrong username/password (401); Iwara changed its API auth flow so the token exchange returns an error; cached `iwara:token` is stale but the route does not refresh it; datacenter IP rate-limited by Iwara (429); Iwara temporarily down (5xx).","solutions":["Inspect the interpolated status code in the message: 401/403 → recheck credentials; 429 → slow down / use a proxy; 5xx → wait and retry later.","Clear the `iwara:token` cache entry so the route re-runs login with fresh credentials.","Confirm `IWARA_USERNAME`/`IWARA_PASSWORD` are correct by logging in on iwara.tv in a browser.","If IP-blocked, route RSSHub egress through a proxy."],"exampleFix":"// before: stale cached token causes 401 on subsequent calls\n// after: clear the cached token and let the route re-login\ncache.del('iwara:token'); // then retry the route","handlingStrategy":"try-catch","validationCode":"// pre-flight: confirm creds before launching the browser\nif (!config.iwara?.username || !config.iwara?.password) throw new ConfigNotFoundError('Iwara creds missing');","typeGuard":"const isOkStatus = (s: number) => s >= 200 && s < 300;","tryCatchPattern":"try {\n  const data = await fetchApi(url, options);\n} catch (e) {\n  const status = (e as Error).message.match(/status: (\\d+)/)?.[1];\n  if (status === '401' || status === '403') { await cache.del('iwara:token'); /* force re-login */ }\n  throw e;\n}","preventionTips":["Clear the cached 'iwara:token' on 401/403 so the route re-runs login.","Back off on 429 (rate limit).\nLog the status code for diagnosis."],"tags":["iwara","http-status","authentication","playwright","rate-limit"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}