{"record":{"id":"ba4d62acfe2ec3e9","repo":"DIYgod/RSSHub","slug":"nuxt","errorCode":null,"errorMessage":"Nuxt 框架信息提取失败，请报告这个问题","messagePattern":"Nuxt 框架信息提取失败，请报告这个问题","errorType":"exception","errorClass":"Error","httpStatus":503,"severity":"error","filePath":"lib/routes/nintendo/utils.ts","lineNumber":23,"sourceCode":"import localizedFormat from 'dayjs/plugin/localizedFormat.js';\nimport { JSDOM } from 'jsdom';\n\nimport got from '@/utils/got';\nimport { parseDate } from '@/utils/parse-date';\n\nimport { renderEshopCnDescription } from './templates/eshop-cn';\n\ndayjs.extend(localizedFormat);\n\nfunction nuxtReader(data) {\n    let nuxt: Record<string, unknown>;\n    try {\n        const dom = new JSDOM(data, {\n            runScripts: 'dangerously',\n        });\n        nuxt = dom.window.__NUXT__.data[0];\n    } catch {\n        throw new Error('Nuxt 框架信息提取失败，请报告这个问题');\n    }\n\n    return nuxt;\n}\n\nfunction generateImageLink(link) {\n    return `<img src=\"${link}\"><br/>`;\n}\n\nasync function loadContent(link) {\n    const response = await got(link);\n\n    const data = response.data;\n\n    const $ = load(data); // 使用 cheerio 加载返回的 HTML\n    const description = $('.description').html();\n\n    return {","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/nintendo/utils.ts#L5-L41","documentation":"A plain Error thrown by util.nuxtReader when JSDOM fails to parse the page or when dom.window.__NUXT__.data[0] is undefined. nuxtReader wraps the JSDOM construction in try/catch and converts any failure — parse error, script execution error, or missing __NUXT__ global — into a single Chinese 'Nuxt extraction failed, please report' message. This is the root-cause guard that 407/408 depend on.","triggerScenarios":"JSDOM throws during construction (malformed HTML, script execution error under runScripts: 'dangerously'), or the page no longer exposes window.__NUXT__ (migrated away from Nuxt, SSR data moved to a __NUXT__-shaped JSON island, or a different data index). The catch-all hides the original error.","commonSituations":"Site migrates off Nuxt or bumps to a version with a different data layout; a script on the page throws under JSDOM and aborts __NUXT__ assignment; the page is behind a WAF returning non-HTML; JSDOM security/sandbox restrictions.","solutions":["Temporarily widen the catch to log the original error (catch (e) { logger.error(e); throw ... }) to identify whether it is a parse failure, a script error, or a missing global.","Open the target URL and inspect window.__NUXT__ shape — confirm data is still an array at index 0.","If the site moved data into a <script id=__NEXT_DATA__> or inline JSON, switch to parsing that instead of JSDOM script execution.","If JSDOM cannot run the page scripts, extract the __NUXT__ payload via regex on the raw HTML."],"exampleFix":"// before\ntry {\n    const dom = new JSDOM(data, { runScripts: 'dangerously' });\n    nuxt = dom.window.__NUXT__.data[0];\n} catch {\n    throw new Error('Nuxt 框架信息提取失败，请报告这个问题');\n}\n\n// after — preserve the root cause\ntry {\n    const dom = new JSDOM(data, { runScripts: 'dangerously' });\n    nuxt = dom.window.__NUXT__.data[0];\n} catch (e) {\n    logger.error('nuxtReader failed:', e);\n    throw new Error(`Nuxt 框架信息提取失败: ${e?.message ?? e}`);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"const hasNuxtData = (dom): dom is { window: { __NUXT__: { data: any[] } } } =>\n  !!dom?.window?.__NUXT__ && Array.isArray(dom.window.__NUXT__.data) && !!dom.window.__NUXT__.data[0];","tryCatchPattern":"// Preserve the original error so the cause is not swallowed.\ntry {\n  const dom = new JSDOM(data, { runScripts: 'dangerously' });\n  if (!dom.window.__NUXT__?.data?.[0]) throw new Error('no __NUXT__.data[0]');\n  return dom.window.__NUXT__.data[0];\n} catch (e) {\n  logger.error('nuxtReader root cause:', e);\n  throw new Error(`Nuxt 框架信息提取失败: ${e?.message ?? e}`);\n}","preventionTips":["Never swallow the original error in a catch-all — log or chain it.","Guard __NUXT__ existence with optional chaining before indexing data[0].","If the site drops Nuxt, switch to regex extraction of the inline JSON payload as a fallback."],"tags":["nuxt","jsdom","scraping","nintendo","error-swallowing"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}