DIYgod/RSSHub · error · Error

Nuxt 框架信息提取失败,请报告这个问题

Error message

Nuxt 框架信息提取失败,请报告这个问题

What it means

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.

Source

Thrown at lib/routes/nintendo/utils.ts:23

import localizedFormat from 'dayjs/plugin/localizedFormat.js';
import { JSDOM } from 'jsdom';

import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';

import { renderEshopCnDescription } from './templates/eshop-cn';

dayjs.extend(localizedFormat);

function nuxtReader(data) {
    let nuxt: Record<string, unknown>;
    try {
        const dom = new JSDOM(data, {
            runScripts: 'dangerously',
        });
        nuxt = dom.window.__NUXT__.data[0];
    } catch {
        throw new Error('Nuxt 框架信息提取失败,请报告这个问题');
    }

    return nuxt;
}

function generateImageLink(link) {
    return `<img src="${link}"><br/>`;
}

async function loadContent(link) {
    const response = await got(link);

    const data = response.data;

    const $ = load(data); // 使用 cheerio 加载返回的 HTML
    const description = $('.description').html();

    return {

View on GitHub (pinned to bed535e087)

Solutions

  1. 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.
  2. Open the target URL and inspect window.__NUXT__ shape — confirm data is still an array at index 0.
  3. If the site moved data into a <script id=__NEXT_DATA__> or inline JSON, switch to parsing that instead of JSDOM script execution.
  4. If JSDOM cannot run the page scripts, extract the __NUXT__ payload via regex on the raw HTML.

Example fix

// before
try {
    const dom = new JSDOM(data, { runScripts: 'dangerously' });
    nuxt = dom.window.__NUXT__.data[0];
} catch {
    throw new Error('Nuxt 框架信息提取失败,请报告这个问题');
}

// after — preserve the root cause
try {
    const dom = new JSDOM(data, { runScripts: 'dangerously' });
    nuxt = dom.window.__NUXT__.data[0];
} catch (e) {
    logger.error('nuxtReader failed:', e);
    throw new Error(`Nuxt 框架信息提取失败: ${e?.message ?? e}`);
}
Defensive patterns

Strategy: try-catch

Type guard

const hasNuxtData = (dom): dom is { window: { __NUXT__: { data: any[] } } } =>
  !!dom?.window?.__NUXT__ && Array.isArray(dom.window.__NUXT__.data) && !!dom.window.__NUXT__.data[0];

Try / catch

// Preserve the original error so the cause is not swallowed.
try {
  const dom = new JSDOM(data, { runScripts: 'dangerously' });
  if (!dom.window.__NUXT__?.data?.[0]) throw new Error('no __NUXT__.data[0]');
  return dom.window.__NUXT__.data[0];
} catch (e) {
  logger.error('nuxtReader root cause:', e);
  throw new Error(`Nuxt 框架信息提取失败: ${e?.message ?? e}`);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12). Data as JSON: /api/errors/ba4d62acfe2ec3e9. Report an issue: GitHub.