DIYgod/RSSHub · error · Error
Failed to fetch Wikipedia current events: ${message}
Error message
Failed to fetch Wikipedia current events: ${message} What it means
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.
Source
Thrown at lib/routes/wikipedia/current-events.ts:405
description: html,
// we estimate pubDate by taking the min of the latest possible entry and current time
pubDate: new Date(Math.min(endOfDayGMTMinus12, Date.now())),
guid: `wikipedia-current-events-${dateStr}`,
};
}
return null;
})
.filter((item) => item !== null);
return {
title: 'Wikipedia: Portal: Current events',
link: 'https://en.wikipedia.org/wiki/Portal:Current_events',
description: 'Current events from Wikipedia - Latest news and events',
item: items,
};
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
throw new Error(`Failed to fetch Wikipedia current events: ${message}`, { cause: error });
}
}
function determineDates(includeToday: any) {
const now = new Date();
const currentHourUTC = now.getUTCHours();
let shouldIncludeToday = false;
switch (includeToday) {
case 'always':
shouldIncludeToday = true;
break;
case 'never':
shouldIncludeToday = false;
break;View on GitHub (pinned to bed535e087)
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.
Defensive patterns
Strategy: try-catch
Validate before calling
// Validate reachability before the heavy parse
try {
await got.head('https://en.wikipedia.org/wiki/Portal:Current_events', { timeout: 5000 });
} catch (e) {
throw new Error('Wikipedia unreachable; aborting before parse attempt');
} Type guard
function isWikipediaFetchError(e: unknown): boolean {
return e instanceof Error && /Failed to fetch Wikipedia current events/i.test(e.message);
} Try / catch
try {
return await buildCurrentEventsFeed();
} catch (e) {
const root = isWikipediaFetchError(e) ? (e.cause ?? e) : e;
if (root instanceof Error && /ETIMEDOUT|ENOTFOUND|getaddrinfo/i.test(root.message)) {
// transient network — schedule a retry
await scheduleRetry();
}
throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Wikipedia changed the page structure, transient network/HTTP error, RSSHub egress blocked, or a date-parsing edge case in determineDates/assembly logic.
Related errors
- Error fetching academic information: ${error}
- Error fetching announcements: ${error}
- No response body
- No article body
- Unable to fetch message feed from this channel. Please check
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/301a211a6197bca8.
Report an issue: GitHub.