DIYgod/RSSHub · error · Error
missing next data
Error message
missing next data
What it means
Thrown by the League of Legends patch-notes handler when the scraped LOL news page contains no <script id="__NEXT_DATA__"> element. The handler relies entirely on that Next.js data island to get the patch list (JSON.parse(nextData).props.pageProps.page.blades[2].items); without it, there is nothing to render.
Source
Thrown at lib/routes/leagueoflegends/patch-notes.ts:30
{
source: ['www.leagueoflegends.com/en-us/news/tags/patch-notes/', 'www.leagueoflegends.com/en-us/news/game-updates/:postSlug'],
},
],
name: 'Patch Notes',
maintainers: ['noahm'],
async handler() {
const url = 'https://www.leagueoflegends.com/en-us/news/tags/patch-notes/';
const response = await got({
method: 'get',
url,
});
const data = response.data;
const $ = load(data);
const nextData = $('script[id="__NEXT_DATA__"]').text();
if (!nextData) {
throw new Error('missing next data');
}
const list: PatchNotesItem[] = JSON.parse(nextData).props.pageProps.page.blades[2].items;
return {
title: 'League of Legends Patch Notes',
link: url,
item: list.map((item): DataItem => ({
title: item.title,
description: item.description.body,
pubDate: parseDate(item.publishedAt),
link: item.action.payload.url,
guid: item.analytics.contentId,
image: item.media.url,
itunes_item_image: item.media.url,
})),
};
},
};View on GitHub (pinned to bed535e087)
Solutions
- Open the URL in an incognito browser, view-source, and confirm whether id="__NEXT_DATA__" still exists
- If renamed, update the selector in lib/routes/leagueoflegends/patch-notes.ts:28 (e.g. to __APP_DATA__)
- If the page now renders client-side only, switch to Puppeteer/Playwright (requirePuppeteer) so the script is populated
- Add a real User-Agent via got headers in case the missing data is from a bot-filtered response
Example fix
// before
const nextData = $('script[id="__NEXT_DATA__"]').text();
if (!nextData) {
throw new Error('missing next data');
}
// after — try both Next.js data island shapes
const nextData = $('script[id="__NEXT_DATA__"]').text() || $('script[id="__APP_DATA__"]').text();
if (!nextData) {
throw new Error('missing next/app data — LOL site may have migrated; check selectors');
} Defensive patterns
Strategy: try-catch
Validate before calling
async function hasNextData(url: string): Promise<boolean> {
const resp = await got({ method: 'get', url });
const $ = load(resp.data);
return $('script[id="__NEXT_DATA__"]').text().length > 0 || $('script[id="__APP_DATA__"]').text().length > 0;
} Type guard
interface NextDataEnvelope { props?: { pageProps?: { page?: { blades?: { items?: unknown[] }[] } } } }
function hasNextDataShape(v: unknown): v is NextDataEnvelope {
const blades = (v as NextDataEnvelope)?.props?.pageProps?.page?.blades;
return Array.isArray(blades) && blades.length > 2 && Array.isArray(blades[2]?.items);
} Try / catch
try { return await handler(); }
catch (e) {
if (e instanceof Error && e.message === 'missing next data') {
// likely SSR migrated or bot-filtered — retry with a real UA, then advise enabling Puppeteer
throw new Error('LOL patch notes: __NEXT_DATA__ missing — site migrated or request was bot-filtered');
}
throw e;
} Prevention
- Send a realistic User-Agent to avoid bot-filtered responses
- Try both __NEXT_DATA__ and __APP_DATA__ selectors
- Switch to requirePuppeteer if the page renders client-side only
- Pin a content-type check to detect HTML-vs-non-HTML responses
When it happens
Trigger: GET https://www.leagueoflegends.com/en-us/news/tags/patch-notes/ returns HTML but the __NEXT_DATA__ script is absent — because riotgames migrated away from Next.js, changed the script id, rendered client-side only (cheerio/load cannot execute JS), or returned an anti-bot/consent page instead of the real content.
Common situations: Site rebuild removing/renaming __NEXT_DATA__; consent/region-redirect page intercepting the request; the data moved to a different blade index or a different data island (e.g. __APP_DATA__); got() received a non-HTML body.
Related errors
- 无法从页面中获取到帖子ID,可能网站结构已变更
- 请填入合法的用户 id,参见用户排名 https://www.jisilu.cn/users/
- Build ID not found.
- 无法解析页面数据,请检查杂志 ID 是否正确或页面结构是否变动
- 无法解析页面 Props 数据
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/8e3fc4d13b9a548e.
Report an issue: GitHub.