Skip to content

fix: README content truncated for packages with large READMEs #1458

@lukeocodes

Description

@lukeocodes

Problem

The npm registry truncates the readme field in packument JSON responses at exactly 65,536 characters (2^16). This means packages with large READMEs (e.g., vue-data-ui at ~80KB) are rendered incomplete on npmx.dev — the content is silently cut off mid-document.

Reproduction

curl -s "https://registry.npmjs.org/vue-data-ui" | jq '.readme | length'
# Returns: 65536

The actual README is 80,712 bytes, so ~19% of the content is lost.

Root Cause

In server/api/registry/readme/[...pkg].get.ts, the handler reads packageData.readme from the npm packument as the primary source. The jsDelivr CDN fallback (fetchReadmeFromJsdelivr) only triggers when the packument readme is missing or the filename is non-standard — not when it's truncated.

Fix

Prefer fetching the README directly from jsDelivr CDN (which serves the actual file from the npm tarball, untruncated), and fall back to the packument readme field only when jsDelivr doesn't have the file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions