DIYgod/RSSHub · error · Error
No response body
Error message
No response body
What it means
The route fetches the GDUFS (Guangdong University of Foreign Studies) news listing page via got and expects response.body to be present. got normally throws on transport errors, so reaching this check with a falsy body means the server returned a response with an empty body (e.g. a 200 with zero bytes, a HEAD-like response, or a decompression issue). The route fails fast because cheerio cannot parse nothing.
Source
Thrown at lib/routes/gdufs/xwxy/index.ts:30
const pathMap: Record<string, string> = {
news: '/xwzx/xyxw.htm',
notices: '/xwzx/tzgg/tz.htm',
announcements: '/xwzx/tzgg/gg.htm',
media: '/xwzx/mtjj.htm',
};
const titleMap: Record<string, string> = {
news: '学院新闻',
notices: '通知',
announcements: '公告',
media: '媒体聚焦',
};
const datePattern = /\d{4}[-/.]\d{1,2}[-/.]\d{1,2}/;
const link = `${BASE_URL}${pathMap[category] ?? pathMap.news}`;
const response = await got(link);
if (!response.body) {
throw new Error('No response body');
}
const $ = load(response.body);
// 直接选择新闻列表项中的链接
const anchors = $('li[id^="line_u14_"] a');
const items = anchors
.toArray()
.map((el) => {
const a = $(el);
const href = a.attr('href') || '';
const li = a.closest('li');
const contextText = ((li && li.text()) || a.text()).trim();
const dateText = a.find('i').text().trim() || (li && li.find('i').text().trim()) || (li && li.find('time').text().trim()) || (contextText.match(datePattern)?.[0] ?? '');
const pubDate: Date | undefined = dateText ? parseDate(dateText) : undefined;
const title = a.find('h5').text().trim() || a.attr('title')?.trim() || a.text().trim() || contextText.replace(datePattern, '').trim();
// 过滤无效链接
if (!href) {
return null;View on GitHub (pinned to bed535e087)
Solutions
- Retry the request once (transient empty bodies are common on these servers).
- Check response.statusCode — a 3xx to an auth/login page may produce an unexpected body.
- Verify the BASE_URL/pathMap URLs are still correct by opening them in a browser.
- If persistent, switch to ofetch or add an Accept-Encoding header to avoid decompression issues.
Example fix
// before
const response = await got(link);
if (!response.body) {
throw new Error('No response body');
}
// after
let response;
for (const attempt of [0, 1]) {
response = await got(link);
if (response.body) break;
}
if (!response.body) {
throw new Error(`No response body from ${link} (status ${response.statusCode})`);
} Defensive patterns
Strategy: retry
Validate before calling
import ofetch from '@/utils/ofetch';
const head = await ofetch.raw(link, { method: 'HEAD' });
if (head.status >= 400) throw new Error(`${link} returned ${head.status}`); Type guard
const hasBody = (r: { body: unknown }): boolean => !!r.body; Try / catch
let response;
for (let i = 0; i < 2; i++) {
response = await got(link);
if (response.body) break;
}
if (!response.body) throw new Error('No response body'); Prevention
- Retry once on empty bodies (common on university servers). Verify BASE_URL/pathMap URLs are current. Log response.statusCode to distinguish redirects from faults.
When it happens
Trigger: The xwxy (school of journalism) server returns an empty body (maintenance, intermittent server fault, a redirect that got follows to an empty page), or a content-encoding mismatch leaves body undefined after decompression.
Common situations: Chinese university servers going down for maintenance or returning intermittent empty responses; network proxies stripping bodies; rare got decompression edge cases.
Related errors
- No article body
- Unable to fetch message feed from this channel. Please check
- Failed to fetch thread data
- No posts found
- Failed to fetch Wikipedia current events: ${message}
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/a3523c9671bbb37d.
Report an issue: GitHub.