DIYgod/RSSHub · error · Error

HTML 缓存中无章节!

Error message

HTML 缓存中无章节!

What it means

After combining and deduplicating all episode lists (firstEpisodes, latestEpisodes, extraEpisodes) from the comic-walker work data, zero chapters remain. Every episode was either missing a valid 'code' field or was a duplicate, leaving an empty array. The route cannot produce a feed with no items.

Source

Thrown at lib/routes/comic-walker/manga.ts:92

        const coverImage = work.bookCover || work.thumbnail;

        const firstEpisodes = getEpisodes(data.firstEpisodes);
        const latestEpisodes = getEpisodes(data.latestEpisodes);
        const extraEpisodes = getEpisodes(data.episodes);

        const seenCodes = new Set<string>();
        const allChapters = [...firstEpisodes, ...latestEpisodes, ...extraEpisodes]
            .filter((ep) => {
                if (ep?.code && !seenCodes.has(ep.code)) {
                    seenCodes.add(ep.code);
                    return true;
                }
                return false;
            })
            .toSorted((a: any, b: any) => (b.internal?.episodeNo || 0) - (a.internal?.episodeNo || 0));

        if (allChapters.length === 0) {
            throw new Error('HTML 缓存中无章节!');
        }

        const items = allChapters.map((chapter: any) => {
            const epType = chapter.type === 'normal' ? '正篇' : '特别篇/PR';
            const isReadStatus = chapter.isActive ? '' : ' (未解锁/仍需等待)';
            const fullTitle = `${chapter.title}${chapter.subTitle ? ` - ${chapter.subTitle}` : ''}${isReadStatus}`;
            const thumb = chapter.originalThumbnail || chapter.thumbnail;

            const currentPubDate = chapter.updateDate ? parseDate(chapter.updateDate) : undefined;

            return {
                title: fullTitle,
                link: `${baseUrl}/detail/${id}/episodes/${chapter.code}`,
                description: `
                    ${thumb ? `<img src="${thumb}" style="max-width: 100%;"><br>` : ''}
                `,
                guid: `Kadocomi-manga-${chapter.code}`,
                category: epType,

View on GitHub (pinned to bed535e087)

Solutions

  1. Log the raw data.firstEpisodes, data.latestEpisodes, and data.episodes arrays to check if they contain data.
  2. Inspect individual episode objects to verify the 'code' field still exists and is populated.
  3. If episodes exist but lack 'code', check if a different unique identifier field should be used for deduplication.
  4. Consider returning an empty feed with allowEmpty: true instead of throwing, if zero episodes is a legitimate state.

Example fix

// before
if (allChapters.length === 0) {
    throw new Error('HTML 缓存中无章节!');
}

// after — log raw counts for diagnosis
if (allChapters.length === 0) {
    const raw = firstEpisodes.length + latestEpisodes.length + extraEpisodes.length;
    throw new Error(`No chapters after dedup. Raw episode count: ${raw}. Check if 'code' field exists on episodes.`);
}
Defensive patterns

Strategy: validation

Validate before calling

const rawEpisodeCount = firstEpisodes.length + latestEpisodes.length + extraEpisodes.length;
if (rawEpisodeCount === 0) {
    throw new Error('No episodes found in any episode list — manga may have no published content');
}
// Then check after dedup
if (allChapters.length === 0) {
    throw new Error(`All ${rawEpisodeCount} episodes filtered out — check 'code' field presence`);
}

Type guard

function episodeHasCode(ep: any): ep is { code: string; title: string } {
    return ep != null && typeof ep.code === 'string' && ep.code.length > 0;
}

Prevention

When it happens

Trigger: The filter chain removes all episodes because: (1) the three episode arrays were all empty in the API response, (2) every episode lacked an ep.code property (filtered out by the `if (ep?.code && ...)` guard), or (3) all episodes shared the same code and were deduplicated to one, then the filter's return logic still failed to retain them.

Common situations: The manga is upcoming and has no published episodes yet; the API response changed episode field names (e.g., 'code' renamed to 'episodeCode'); episodes exist in the raw data but get filtered out because the code field is null for preview/locked content; the manga is region-locked and the API returns metadata without episodes.

Related errors


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