{"record":{"id":"301a211a6197bca8","repo":"DIYgod/RSSHub","slug":"failed-to-fetch-wikipedia-current-events-messag","errorCode":null,"errorMessage":"Failed to fetch Wikipedia current events: ${message}","messagePattern":"Failed to fetch Wikipedia current events: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":503,"severity":"error","filePath":"lib/routes/wikipedia/current-events.ts","lineNumber":405,"sourceCode":"                        description: html,\n                        // we estimate pubDate by taking the min of the latest possible entry and current time\n                        pubDate: new Date(Math.min(endOfDayGMTMinus12, Date.now())),\n                        guid: `wikipedia-current-events-${dateStr}`,\n                    };\n                }\n                return null;\n            })\n            .filter((item) => item !== null);\n\n        return {\n            title: 'Wikipedia: Portal: Current events',\n            link: 'https://en.wikipedia.org/wiki/Portal:Current_events',\n            description: 'Current events from Wikipedia - Latest news and events',\n            item: items,\n        };\n    } catch (error) {\n        const message = error instanceof Error ? error.message : String(error);\n        throw new Error(`Failed to fetch Wikipedia current events: ${message}`, { cause: error });\n    }\n}\nfunction determineDates(includeToday: any) {\n    const now = new Date();\n    const currentHourUTC = now.getUTCHours();\n\n    let shouldIncludeToday = false;\n\n    switch (includeToday) {\n        case 'always':\n            shouldIncludeToday = true;\n\n            break;\n\n        case 'never':\n            shouldIncludeToday = false;\n\n            break;","sourceCodeStart":387,"sourceCodeEnd":423,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/wikipedia/current-events.ts#L387-L423","documentation":"A catch-all wrapper around the entire Wikipedia current-events handler. Any error thrown while fetching/parsing en.wikipedia.org Portal:Current_events is re-thrown with a 'Failed to fetch...' prefix and the original attached via { cause: error }, preserving the stack chain.","triggerScenarios":"Network failure hitting wikipedia.org, a JSON.parse/regex failure on the response, or any exception inside the items-building pipeline bubbles to the try/catch at current-events.ts:403-406.","commonSituations":"Wikipedia changed the page structure, transient network/HTTP error, RSSHub egress blocked, or a date-parsing edge case in determineDates/assembly logic.","solutions":["Read error.cause (and its message) — the prefix is generic; the root cause is in the chained error.","Retry after confirming network reachability to en.wikipedia.org.","If persistent, inspect the page HTML at the failing date to see if the parser selectors need updating, and report to maintainers."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Validate reachability before the heavy parse\ntry {\n    await got.head('https://en.wikipedia.org/wiki/Portal:Current_events', { timeout: 5000 });\n} catch (e) {\n    throw new Error('Wikipedia unreachable; aborting before parse attempt');\n}","typeGuard":"function isWikipediaFetchError(e: unknown): boolean {\n    return e instanceof Error && /Failed to fetch Wikipedia current events/i.test(e.message);\n}","tryCatchPattern":"try {\n    return await buildCurrentEventsFeed();\n} catch (e) {\n    const root = isWikipediaFetchError(e) ? (e.cause ?? e) : e;\n    if (root instanceof Error && /ETIMEDOUT|ENOTFOUND|getaddrinfo/i.test(root.message)) {\n        // transient network — schedule a retry\n        await scheduleRetry();\n    }\n    throw e;\n}","preventionTips":["Always read error.cause — the wrapper is intentionally generic.","Distinguish network errors (retryable) from parse errors (need a selector fix).","Pin a fixture of the wikipedia page in tests to catch selector drift."],"tags":["wikipedia","network","error-wrapping","scraping"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}