Skip to content

perf(npm-resolver): normalize non-abbreviated registry metadata - #12772

Merged
zkochan merged 4 commits into
pnpm:mainfrom
astegmaier:ansteg/normalize-registry-metadata-at-network-layer
Jul 4, 2026
Merged

zkochan merged 4 commits into
pnpm:mainfrom
astegmaier:ansteg/normalize-registry-metadata-at-network-layer

Conversation

@astegmaier

@astegmaier astegmaier commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

pnpm requests abbreviated package metadata (Accept: application/vnd.npm.install-v1+json) — the slim document with only the fields needed to install. Some registries ignore that header and return the full document (npm's abbreviated format is a vendor convention, not something every registry implements). Azure DevOps Artifacts is one such registry: it always returns the full CouchDB document, including per-version scripts, exports, devDependencies, readme, and arbitrary custom package.json fields.

pnpm stored that response verbatim in the abbreviated metadata cache, so every later resolution re-read and re-parsed all of those unused fields.

This PR fixes the malformed response at the boundary where it enters pnpm — the network/fetch layer. The fetch layer inspects the response Content-Type: an abbreviated request that comes back as anything other than application/vnd.npm.install-v1+json means the registry ignored the header and served the full document, so the fetch layer normalizes it down to the abbreviated field set (reusing the existing clearMeta helper) before it enters the in-memory cache, the on-disk mirror, or the resolver. The resolver already ignores the dropped fields, so resolution output is byte-identical — the cache just gets much smaller and faster to parse.

Registries that honor the abbreviated header (e.g. npmjs.org echoes Content-Type: application/vnd.npm.install-v1+json) are detected as already-abbreviated and take an early return: no field stripping, no re-serialization — the happy path pays nothing.

The problem, concretely

On a large monorepo at Microsoft whose workspace resolves against an Azure DevOps Artifacts feed, one internal package's abbreviated metadata was 39.7 MB — of which only ~12% is install-relevant:

field (summed over all versions) share of document
scripts 51%
devDependencies 15%
exports 9%
dependencies (needed) 9%
custom fields (_id, readme, dev-tooling config, …) ~13%
dist (needed) 2%

The same package on the public npm registry (which honors the abbreviated header) is 0.52 MB. I confirmed the registry behavior directly: requesting that package from Azure DevOps with Accept: application/vnd.npm.install-v1+json returns byte-for-byte the same response as Accept: application/json — it does no content negotiation. The public npm registry, by contrast, echoes Content-Type: application/vnd.npm.install-v1+json for the abbreviated request and application/json for the full one — which is exactly the signal this PR keys off.

Because dedupe/resolution parses each package's metadata (potentially once per dependent), the extra ~88% of every document dominates wall time and heap.

The fix

  • fetchMetadataFromFromRegistry (in @pnpm/resolving.npm-resolver) reads the response Content-Type. On an abbreviated request whose response is not the abbreviated content type, it runs clearMeta and re-serializes; otherwise it returns the parsed body untouched.
  • clearMeta is extracted from pickPackage.ts into its own module so the fetch layer can use it without a circular import, and is made null-safe for packages with no versions (unpublished), which the abbreviated path can now reach.
  • Because the fetch layer now guarantees abbreviated shape, pickPackage needs no abbreviated-slot special-casing — it keeps only its pre-existing filterMetadata (full-slot) narrowing.

Why resolution is unchanged

clearMeta keeps every field the resolver reads (dependencies/optionalDependencies/peerDependencies*/dist/engines/cpu/os/libc/bin/bundleDependencies/deprecated/hasInstallScript/_npmUser) and the top-level time (so minimumReleaseAge still works). Resolution output is therefore byte-identical; only the size of the cached document changes.

Performance

Warm-cache pnpm dedupe --lockfile-only --offline on that monorepo (~5,000 external packages), best of repeated runs:

metadata cache wall peak RSS
full (before) ~138 s 3.59 GB
normalized (after) ~67 s 2.54 GB

Additionally, because the detection happens at fetch time, spec-compliant registries (npmjs.org) skip clearMeta and re-serialization entirely — the extra work only ever runs for registries that actually send full documents.

pacquet port

The equivalent change is included for the Rust stack: both metadata fetchers in pacquet-resolving-npm-resolver (fetch_full_metadata and fetch_full_metadata_cached) now inspect the response Content-Type on abbreviated requests and strip a full document down to the abbreviated field set via the existing clear_meta before it reaches the pick or the on-disk mirror. Media-type detection drops parameters and compares case-insensitively (RFC 9110). Registries that echo the abbreviated content type skip the normalization entirely.

Testing

  • New normalizeAbbreviated.test.ts drives the real fetch path through a mock registry: a full document served with Content-Type: application/json is normalized in the abbreviated cache (unused fields dropped, install fields kept); a document served with the abbreviated content type (uppercased, with a charset parameter) is cached verbatim (no stripping, no re-serialization), proving the happy path is untouched.
  • @pnpm/resolving.npm-resolver: full suite passes (239 tests), compile + lint + typecheck clean.
  • pacquet: the same two scenarios are ported to fetch_full_metadata_cached/tests.rs; pacquet-resolving-npm-resolver suite passes (280 tests), clippy/fmt clean.

Alternative considered: downstream normalization (#12766)

#12766 is an earlier, alternative implementation of the same behavior that applies clearMeta one layer up, in pickPackage, on the abbreviated slot. It produces a byte-identical cache and byte-identical resolution output. This PR is proposed as the preferable variant because:

  • It fixes the problem where it originates — a non-conformant network response — so every consumer of the fetch result gets correctly-shaped data, not just the one call site.
  • The happy path pays nothing. perf(npm-resolver): normalize non-abbreviated registry metadata before caching #12766 runs clearMeta on every abbreviated response, including npmjs.org's already-slim documents; this PR skips it via the Content-Type check.
  • It removes, rather than adds, resolver complexity — the abbreviated-slot branching (upgradedToFull tracking, the dual jsonForDisk path) disappears.

Only one of the two PRs should land.

Note on the media-type constant

The abbreviated media type application/vnd.npm.install-v1+json is intentionally kept as a small local const in fetch.ts. It also exists (module-private, unexported) in @pnpm/network.fetch, which uses it to build the request Accept header. Two other placements were considered and rejected:

  • Export it from @pnpm/network.fetch — the resolver only depends on that package as a devDependency (the FetchFromRegistry function is injected, not imported), so consuming a value from it would force a new runtime dependency and couple the resolver to the network package's internals.
  • Add it to @pnpm/constants — viable (the resolver already imports the *_META_DIR constants from there), but it would only fully de-duplicate if @pnpm/network.fetch also took a dependency on @pnpm/constants, which it currently does not.

Neither seemed worth a change to the dependency graph to share a single stable string, so the constant is duplicated locally with a comment.

Squash Commit Body

pnpm requests abbreviated package metadata (Accept:
application/vnd.npm.install-v1+json). Some registries (e.g. Azure DevOps
Artifacts) ignore that header and return the full CouchDB document, including
per-version fields the installer never reads (scripts, exports, devDependencies,
readme, custom package.json fields). pnpm stored that response verbatim in the
abbreviated metadata cache, so every later resolution re-read and re-parsed
those unused fields.

Fix the response at the boundary where it enters pnpm:
fetchMetadataFromFromRegistry inspects the response Content-Type. When an
abbreviated request comes back with anything other than
application/vnd.npm.install-v1+json, the registry ignored the header and served
the full document, so the fetch layer strips it to the abbreviated field set
(via the existing clearMeta helper) and re-serializes. Registries that honor the
header (the npm registry echoes the abbreviated Content-Type) take an early
return: no clearMeta, no re-serialization.

clearMeta is extracted from pickPackage.ts into its own module so the network
layer can use it without a circular import, and is made null-safe on versions.
pickPackage's abbreviated slot no longer needs special-casing.

Alternative to pnpm/pnpm#12766, which applied the same normalization in
pickPackage; both produce a byte-identical cache, this variant skips the work
for spec-compliant registries and removes resolver special-casing.

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust pacquet/ port, or the description notes what still needs porting.
  • Added a changeset (pnpm changeset) if this PR changes any published package.
  • Added or updated tests.
  • Updated the documentation if needed. — no user-facing docs affected.

Written by an agent (GitHub Copilot CLI, claude-opus-4.8).

Summary by CodeRabbit

  • New Features

    • Registry package metadata caching now detects when a registry ignores abbreviated metadata requests, and automatically normalizes cached responses to a slimmer “abbreviated” shape while keeping resolution results unchanged.
  • Bug Fixes

    • Ensures install-irrelevant fields are stripped only when the abbreviated format isn’t honored; cached metadata remains verbatim when the registry returns the abbreviated media type.
  • Tests

    • Added coverage for both behaviors (ignored vs honored abbreviated metadata), including assertions about what gets persisted in the cache/mirror.

@coderabbitai

coderabbitai Bot commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d7134881-71dc-48d3-8c40-e9c1c043c1ea

📥 Commits

Reviewing files that changed from the base of the PR and between 65c9bd8 and 43635c9.

📒 Files selected for processing (1)
  • pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata/tests.rs

📝 Walkthrough

Walkthrough

Adds abbreviated-metadata normalization helpers, applies them in pnpm and pacquet registry fetch paths when registries return full documents, and adds tests plus a changeset covering the caching behavior.

Changes

Registry metadata normalization

Layer / File(s) Summary
Shared metadata reducer
pnpm11/resolving/npm-resolver/src/clearMeta.ts, pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata.rs
Adds the abbreviated npm packument reducer, abbreviated content-type detection, and fallback normalization helpers.
Registry fetch normalization
pnpm11/resolving/npm-resolver/src/fetch.ts, pnpm11/resolving/npm-resolver/src/pickPackage.ts, pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata_cached.rs
Wires abbreviated-response detection into pnpm and pacquet fetch paths, normalizes full documents before caching, and replaces pnpm’s local clearMeta implementation with the shared helper.
Cached metadata tests and changeset
pnpm11/resolving/npm-resolver/test/normalizeAbbreviated.test.ts, pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata_cached/tests.rs, .changeset/normalize-registry-metadata-at-network-layer.md
Adds tests for normalized full responses versus verbatim abbreviated caching, plus a changeset documenting the patch.
Accept header alignment test
pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata/tests.rs
Adds a unit test that checks the abbreviated Accept header matches the abbreviated response-detection media type prefix.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Registry
  participant fetch as fetchMetadataFromFromRegistry
  participant normalize as normalizeAbbreviatedResponse
  participant clearMeta as clearMeta

  Registry-->>fetch: meta, jsonText, content-type
  fetch->>normalize: normalizeAbbreviatedResponse(meta, jsonText, headers)
  alt full document returned for abbreviated request
    normalize->>clearMeta: clearMeta(meta)
    clearMeta-->>normalize: reduced meta
    normalize-->>fetch: reduced meta, re-serialized jsonText
  else abbreviated document returned
    normalize-->>fetch: original meta, jsonText
  end
Loading

Possibly related PRs

  • pnpm/pnpm#11622: Also touches pnpm’s abbreviated registry metadata caching path and the pickPackage.ts metadata handling used by that pipeline.
  • pnpm/pnpm#11704: Uses abbreviated cached metadata in resolver logic, including fields produced by the metadata normalization path changed here.
  • pnpm/pnpm#11794: Updates the pacquet npm-resolver abbreviated/full metadata request flow, which is the same fetch path extended by this change.

Suggested labels: product: pnpm@11, product: pacquet

Suggested reviewers: zkochan

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@astegmaier astegmaier changed the title perf(npm-resolver): normalize non-abbreviated registry metadata at the network layer perf(npm-resolver): normalize non-abbreviated registry metadata Jul 3, 2026
@astegmaier
astegmaier marked this pull request as ready for review July 3, 2026 20:21
@astegmaier
astegmaier requested a review from zkochan as a code owner July 3, 2026 20:21
Copilot AI review requested due to automatic review settings July 3, 2026 20:21
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

perf(npm-resolver): normalize non-abbreviated registry metadata

✨ Enhancement 🧪 Tests 🕐 20-40 Minutes

Grey Divider

AI Description

• Detect registries that ignore abbreviated packument requests via response Content-Type.
• Normalize full packuments to the abbreviated field set before caching.
• Add regression tests to ensure compliant registries take the zero-cost path.
Diagram

graph TD
  R{{"Registry"}} --> F["fetch.ts"] --> D{"Abbrev CT?"} -->|"Yes"| C[("Abbrev cache")] --> P["npm resolver"]
  D -->|"No"| M["clearMeta.ts"] --> C

  subgraph Legend
    direction LR
    _ext{{"External"}} ~~~ _svc["Module"] ~~~ _dec{"Decision"} ~~~ _db[("Cache")]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Normalize in resolver (pickPackage) for all abbreviated responses
  • ➕ No need to branch on response Content-Type
  • ➕ Keeps network layer simpler
  • ➖ Adds overhead on the compliant happy path (extra stripping + re-serialization)
  • ➖ Keeps special-case logic in resolver/caching instead of fixing at boundary
  • ➖ Doesn't guarantee normalized shape for other downstream consumers of fetch results
2. Always request full metadata and rely on downstream filtering
  • ➕ Avoids abbreviated negotiation differences across registries
  • ➕ Single metadata format to handle
  • ➖ Worst-case bandwidth/CPU/memory for all users, even on compliant registries
  • ➖ Does not address the core performance issue for large packuments

Recommendation: Prefer the network-layer, Content-Type–gated normalization in this PR: it fixes non-conformant registry behavior at the ingress point, guarantees abbreviated-shape data for caches/resolver, and preserves a zero-cost path for registries that correctly return application/vnd.npm.install-v1+json.

Files changed (5) +230 / -40

Enhancement (1) +39 / -2
fetch.tsNormalize non-abbreviated responses on abbreviated fetches +39/-2

Normalize non-abbreviated responses on abbreviated fetches

• Adds Content-Type detection for abbreviated metadata requests and applies clearMeta + re-serialization only when the registry returns a full document. Keeps compliant registries on a fast path by returning parsed body/jsonText verbatim when Content-Type indicates abbreviated metadata.

pnpm11/resolving/npm-resolver/src/fetch.ts

Refactor (2) +54 / -38
clearMeta.tsExtract and harden clearMeta abbreviation helper +53/-0

Extract and harden clearMeta abbreviation helper

• Moves metadata-stripping logic into a shared module for reuse by fetch and resolver layers. Makes the function null-safe for packages with missing/empty versions.

pnpm11/resolving/npm-resolver/src/clearMeta.ts

pickPackage.tsReuse extracted clearMeta and remove inline implementation +1/-38

Reuse extracted clearMeta and remove inline implementation

• Imports clearMeta from the new module and deletes the local implementation to avoid duplication and enable fetch-layer normalization without circular imports.

pnpm11/resolving/npm-resolver/src/pickPackage.ts

Tests (1) +131 / -0
normalizeAbbreviated.test.tsAdd tests for Content-Type–gated normalization behavior +131/-0

Add tests for Content-Type–gated normalization behavior

• Adds a mock-registry test ensuring full documents served with application/json are normalized before writing the abbreviated cache. Also verifies that responses with the abbreviated content type are cached verbatim (no stripping/re-serialization).

pnpm11/resolving/npm-resolver/test/normalizeAbbreviated.test.ts

Other (1) +6 / -0
normalize-registry-metadata-at-network-layer.mdAdd changeset for resolver perf/cache normalization patch +6/-0

Add changeset for resolver perf/cache normalization patch

• Introduces a changeset bumping @pnpm/resolving.npm-resolver and pnpm with a release note describing Content-Type–based normalization and its perf impact.

.changeset/normalize-registry-metadata-at-network-layer.md

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves performance when resolving packages against registries that ignore pnpm’s abbreviated packument Accept header by normalizing “full” metadata responses down to the abbreviated shape at fetch time (keyed off the response Content-Type), reducing cache size and parse overhead without changing resolution results.

Changes:

  • Normalize non-abbreviated responses for abbreviated metadata requests inside fetchMetadataFromFromRegistry() using clearMeta() when the response Content-Type is not the abbreviated media type.
  • Extract clearMeta() into a shared module so it can be reused by both the fetch path and pickPackage (for filterMetadata).
  • Add coverage that asserts normalization occurs for application/json responses, and that already-abbreviated responses are cached verbatim.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pnpm11/resolving/npm-resolver/src/fetch.ts Adds Content-Type-gated normalization of abbreviated metadata responses before caching.
pnpm11/resolving/npm-resolver/src/clearMeta.ts Extracts clearMeta() into a reusable module and makes it null-safe on versions.
pnpm11/resolving/npm-resolver/src/pickPackage.ts Switches to importing clearMeta() from the new module (removes inline implementation).
pnpm11/resolving/npm-resolver/test/normalizeAbbreviated.test.ts Adds tests covering normalization vs. verbatim caching behavior.
.changeset/normalize-registry-metadata-at-network-layer.md Documents the change and bumps @pnpm/resolving.npm-resolver and pnpm.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jul 3, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (8) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Normalization forces full parse 🐞 Bug ➹ Performance ⭐ New
Description
In pacquet, when an abbreviated request comes back non-abbreviated, normalize_abbreviated_meta()
calls mirror::clear_meta(), which deserializes every version fragment into serde_json::Value.
This adds significant extra CPU and allocation on large packuments and partially negates the
registry crate’s lazy-hydration performance model on this fallback path.
Code

pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata.rs[R127-131]

+        let normalize_to_abbreviated =
+            !opts.full_metadata && !is_abbreviated_content_type(response.headers());
        let raw_body = response.text().await.map_err(|error| FetchMetadataError::BodyRead {
            url: redact_url_credentials(&url),
            error,
Evidence
The new fetcher path normalizes abbreviated requests when Content-Type isn’t the install-v1 media
type, calling normalize_abbreviated_meta(). That helper calls clear_meta(&meta), and
clear_meta() explicitly parses each version fragment via serde_json::from_str::<Value>(&json),
which allocates the very large fields being stripped. The registry crate’s own docs describe
avoiding this work via lazy hydration of raw fragments.

pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata.rs[127-145]
pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata.rs[168-170]
pacquet/crates/resolving-npm-resolver/src/mirror.rs[323-359]
pacquet/crates/registry/src/package_versions.rs[2-16]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`normalize_abbreviated_meta()` relies on `mirror::clear_meta()`, which parses each version fragment into `serde_json::Value` and clones selected keys. For large packuments, this is extra work and allocation on the metadata-fetch hot path, and it undermines the intended “keep fragments raw until needed” design.

### Issue Context
The registry crate intentionally keeps per-version manifests as raw JSON fragments to avoid hydrating/parsing versions that aren’t picked.

### Fix Focus Areas
- pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata.rs[127-180]
- pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata_cached.rs[156-206]
- pacquet/crates/resolving-npm-resolver/src/mirror.rs[323-379]
- pacquet/crates/registry/src/package_versions.rs[2-16]

### Proposed fix
Implement a “streaming” per-version normalizer that **does not** deserialize the whole fragment into `Value`:
- Use `serde_json::Deserializer` + a custom `Visitor`/`MapAccess` loop.
- For keys not in the abbreviated whitelist, deserialize into `serde::de::IgnoredAny` to skip without allocating nested structures/strings.
- For kept keys, deserialize values either into `serde_json::Value` (acceptable for kept fields) or into `Box<RawValue>` when possible to preserve raw subtrees.

Then use this streaming normalizer in `normalize_abbreviated_meta()` instead of `mirror::clear_meta()` (or add a new helper alongside `clear_meta` specialized for abbreviated normalization).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. clearMeta avoidable allocations 🐞 Bug ➹ Performance
Description
When normalizing a full (multi-MB) packument, clearMeta() uses Object.entries() (allocates an
entries array) and ramda.pick() per version, adding avoidable peak memory/CPU overhead on the new
normalization path. This can partially erode the performance win for registries that ignore the
abbreviated Accept header (the exact case this PR now handles).
Code

pnpm11/resolving/npm-resolver/src/clearMeta.ts[R46-49]

+  const versions: PackageMeta['versions'] = Object.create(null)
+  for (const [version, info] of Object.entries(pkg.versions ?? {})) {
+    versions[version] = pick(ABBREVIATED_VERSION_FIELDS, info)
+  }
Evidence
normalizeAbbreviatedResponse() calls clearMeta(meta) whenever fullMetadata is false and the
response Content-Type is not the abbreviated media type; in that case the response is commonly the
full, very large packument. clearMeta() currently enumerates versions via Object.entries(...)
and constructs each version object via ramda.pick(...), both of which allocate extra intermediate
structures on the normalization path.

pnpm11/resolving/npm-resolver/src/fetch.ts[239-250]
pnpm11/resolving/npm-resolver/src/clearMeta.ts[42-49]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`clearMeta()` is now invoked from the fetch layer to normalize unexpectedly-full metadata responses. In this new hot path, `Object.entries(pkg.versions ?? {})` allocates a large intermediate array and `ramda.pick()` adds overhead per version.
## Issue Context
This work runs specifically when the registry returned a full packument for an abbreviated request (typically the largest responses). Extra allocations here can increase peak RSS and CPU on exactly the installs this PR is meant to speed up.
## Fix Focus Areas
- Replace `Object.entries(...)` with a streaming iteration (`for ... in` + `hasOwnProperty`) to avoid allocating the entries array.
- Replace `ramda.pick()` with a small local loop that copies only the whitelisted fields from `info` into a new object. This avoids pulling Ramda into the fetch-layer dependency graph and reduces per-version overhead.
### References
- pnpm11/resolving/npm-resolver/src/clearMeta.ts[42-49]
- pnpm11/resolving/npm-resolver/src/fetch.ts[239-250]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Lost modified timestamp 🐞 Bug ➹ Performance
Description
clearMeta() sets modified from pkg.modified only, so when a registry provides modified only
via time.modified the normalization path drops it and caches modified as undefined. This can
disable createNpmResolutionVerifier's modified-based shortcut and force slower per-version
lookups/full-metadata reads during verification.
Code

pnpm11/resolving/npm-resolver/src/clearMeta.ts[R46-52]

+  return {
+    name: pkg.name,
+    'dist-tags': pkg['dist-tags'],
+    versions,
+    time: pkg.time,
+    modified: pkg.modified,
+  }
Evidence
The new normalization path uses clearMeta(), which currently does not preserve time.modified into
the top-level modified field. The verifier’s modified-based fast path returns early only when
meta.modified is a string, so dropping it forces fallback behavior even if the packument had
time.modified available.

pnpm11/resolving/npm-resolver/src/clearMeta.ts[46-52]
pnpm11/resolving/npm-resolver/src/pickPackage.ts[612-616]
pnpm11/resolving/npm-resolver/src/createNpmResolutionVerifier.ts[717-737]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`clearMeta()` currently returns `modified: pkg.modified` without falling back to `pkg.time?.modified`. When `fetch.ts` normalizes a full packument into abbreviated shape (for registries that ignore the abbreviated `Accept` header), a packument that only carries the timestamp under `time.modified` will lose the package-level `modified` field.
Downstream, the resolution verifier’s abbreviated-metadata shortcut requires `meta.modified` to be a string; if it is missing, the shortcut returns `undefined` and falls back to more expensive per-version lookups/full-metadata paths.
### Issue Context
- `prepareJsonForDisk()` already treats `meta.time?.modified` as the canonical fallback for the modified timestamp, which implies `time.modified` is expected to exist in real metadata.
- The verifier shortcut reads only `meta.modified`.
### Fix Focus Areas
- pnpm11/resolving/npm-resolver/src/clearMeta.ts[46-52]
### Proposed change
Update `clearMeta()` to populate `modified` from `pkg.modified ?? pkg.time?.modified` (keeping `time` unchanged).
Example:

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View more (3)
4. Normalization retried as JSON 🐞 Bug ☼ Reliability
Description
fetchMetadataFromFromRegistry() now executes normalizeAbbreviatedResponse() inside the try/catch
that is explicitly meant to retry only broken JSON, so any exception from
clearMeta()/JSON.stringify() is misclassified as BROKEN_METADATA_JSON and retried. A registry
response with valid JSON but malformed metadata shape (e.g. non-object entries under versions) can
therefore cause wasted retries and resolution failure instead of surfacing a schema error (or safely
skipping normalization).
Code

pnpm11/resolving/npm-resolver/src/fetch.ts[R239-252]

+function normalizeAbbreviatedResponse (
+  { fullMetadata, meta, jsonText, response }: {
+    fullMetadata?: boolean
+    meta: PackageMeta
+    jsonText: string
+    response: RegistryResponse
+  }
+): { meta: PackageMeta, jsonText: string } {
+  if (fullMetadata) return { meta, jsonText }
+  const contentType = response.headers.get('content-type')
+  if (contentType?.includes(ABBREVIATED_META_CONTENT_TYPE)) return { meta, jsonText }
+  const normalized = clearMeta(meta)
+  return { meta: normalized, jsonText: JSON.stringify(normalized) }
+}
Evidence
The fetch path explicitly claims it “only retry broken JSON responses”, but it now also runs
normalization inside that same try/catch. Since clearMeta operates on registry-controlled shapes
without validating each version manifest before calling pick(), normalization can throw on
malformed-but-parseable metadata, triggering the JSON retry path incorrectly.

pnpm11/resolving/npm-resolver/src/fetch.ts[184-202]
pnpm11/resolving/npm-resolver/src/fetch.ts[239-252]
pnpm11/resolving/npm-resolver/src/clearMeta.ts[18-44]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`normalizeAbbreviatedResponse()` can throw (via `clearMeta()` and/or `JSON.stringify()`), but it is invoked inside the `try/catch` block that is intended to handle *only* JSON parsing failures. As a result, shape/normalization errors are incorrectly treated as `BROKEN_METADATA_JSON` and retried.
## Issue Context
Registry metadata is untrusted input. Even if JSON is valid, it may not match expected `PackageMeta` shape (e.g. `versions` values not being objects). The current structure retries and logs as “broken JSON”, which is misleading and can amplify a malformed response into repeated network work.
## Fix Focus Areas
- pnpm11/resolving/npm-resolver/src/fetch.ts[184-222]
- pnpm11/resolving/npm-resolver/src/fetch.ts[239-252]
- pnpm11/resolving/npm-resolver/src/clearMeta.ts[18-44]
### Suggested implementation direction
- Make `clearMeta()` robust to malformed `versions` entries (e.g. skip entries where `info` is not a non-null object), so it doesn’t throw on unexpected shapes.
- Additionally (or alternatively), separate JSON parsing from normalization error handling in `fetchMetadataFromFromRegistry()`:
- Keep the retry loop scoped to `response.text()` + `JSON.parse()` only.
- Handle normalization in a separate `try/catch` that either (a) fails with a more accurate error, or (b) falls back to returning the unnormalized `{ meta, jsonText }` (if you prefer fail-open for perf normalization).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


5. Prototype mutation via versions 🐞 Bug ⛨ Security
Description
clearMeta() assigns registry-controlled version keys into a plain object (versions[version] = …),
so a malicious registry response containing a versions.__proto__ entry can mutate the prototype of
the constructed versions map. This prototype mutation now happens at the fetch boundary
(normalizeAbbreviatedResponse → clearMeta), making resolver/cache behavior depend on
attacker-controlled object shape rather than a plain dictionary.
Code

pnpm11/resolving/npm-resolver/src/clearMeta.ts[R19-23]

+  const versions: PackageMeta['versions'] = {}
+  for (const [version, info] of Object.entries(pkg.versions ?? {})) {
+    // The list taken from https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md#abbreviated-version-object
+    // with the addition of 'libc'
+    versions[version] = pick([
Evidence
The fetch layer parses registry-controlled JSON and, when it decides the response was not already
abbreviated, calls clearMeta(meta). clearMeta then constructs a {} and assigns registry-provided
version keys into it, which is the JS pattern that allows __proto__/special-key prototype mutation
on untrusted data. Downstream code treats meta.versions as a dictionary and performs direct
property lookups, so ensuring it is a safe map type avoids attacker-controlled object-shape
surprises.

pnpm11/resolving/npm-resolver/src/fetch.ts[186-252]
pnpm11/resolving/npm-resolver/src/clearMeta.ts[18-44]
pnpm11/resolving/npm-resolver/src/pickPackage.ts[284-304]
pnpm11/resolving/registry/types/src/index.ts[7-14]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`clearMeta()` builds `versions` as a normal object (`{}`) and writes registry-controlled keys into it. Keys like `__proto__` can trigger prototype mutation when assigned via bracket notation, which is undesirable on attacker-controlled registry responses.
## Issue Context
This helper is now called from the fetch layer when normalizing abbreviated metadata responses.
## Fix Focus Areas
- pnpm11/resolving/npm-resolver/src/clearMeta.ts[19-44]
## Suggested fix
- Initialize `versions` with a null prototype, e.g.:
- `const versions = Object.create(null) as PackageMeta['versions']`
- (Optional hardening) Consider similarly using null-prototype maps for any other newly-constructed dictionaries keyed by registry-controlled strings, and/or explicitly reject `__proto__`, `constructor`, `prototype` keys.
- (Optional) Add a unit test ensuring a `versions: { "__proto__": { ... } }` input does not change `Object.getPrototypeOf(result.versions)`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


6. Brittle Content-Type detection 🐞 Bug ➹ Performance
Description
normalizeAbbreviatedResponse() decides whether to skip normalization via a case-sensitive substring
match on the registry-controlled Content-Type, so non-canonical values (casing, lookalike types,
etc.) can incorrectly skip or trigger normalization. This reduces the reliability of the intended
performance win because a registry can return a full packument while still matching (or nearly
matching) the abbreviated media type check.
Code

pnpm11/resolving/npm-resolver/src/fetch.ts[R247-251]

+  if (fullMetadata) return { meta, jsonText }
+  const contentType = response.headers.get('content-type')
+  if (contentType?.includes(ABBREVIATED_META_CONTENT_TYPE)) return { meta, jsonText }
+  const normalized = clearMeta(meta)
+  return { meta: normalized, jsonText: JSON.stringify(normalized) }
Evidence
The normalization decision is currently based on a substring match of Content-Type, which is both
case-sensitive and not an exact media-type comparison; the test fixture shows full packuments
commonly include _id and readme, which can be used for a cheap fallback heuristic if desired.

pnpm11/resolving/npm-resolver/src/fetch.ts[184-199]
pnpm11/resolving/npm-resolver/src/fetch.ts[239-252]
pnpm11/resolving/npm-resolver/test/normalizeAbbreviated.test.ts[22-47]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`normalizeAbbreviatedResponse()` currently treats the response as “already abbreviated” when `content-type.includes('application/vnd.npm.install-v1+json')` is true. This is brittle because it is a **case-sensitive substring** check on a **registry-controlled** header, so non-canonical header formatting (or lookalike values) can prevent normalization and undermine the intended cache-size/perf improvement.
### Issue Context
You already have a cheap early return to keep the happy path free of field stripping/serialization. The goal is to keep that property, but make the detection more robust.
### How to fix
- Parse the media type token robustly and compare **exactly** (case-insensitive):
- `const mediaType = contentType?.split(';', 1)[0].trim().toLowerCase()`
- compare to `ABBREVIATED_META_CONTENT_TYPE` lowercased.
- (Optional but recommended) Add a very cheap body-based fallback for mislabelled registries: if `fullMetadata` is false and the body has obvious full-packument markers (e.g. `_id`/`_rev`/`readme` at top-level as seen in the test fixture), normalize even when `Content-Type` claims abbreviated.
### Fix Focus Areas
- pnpm11/resolving/npm-resolver/src/fetch.ts[239-252]
- pnpm11/resolving/npm-resolver/test/normalizeAbbreviated.test.ts[22-47]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Informational

7. Warn log lacks attribution 🐞 Bug ◔ Observability ⭐ New
Description
When pacquet abbreviated normalization fails, the warning log omits the package name (and any
URL/registry context), making it hard to identify which dependency/registry caused the cache to
retain a full document. This reduces debuggability of the exact “why is my metadata cache huge/slow”
scenario this PR targets.
Code

pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata.rs[R169-177]

+    match clear_meta(&meta) {
+        Ok(normalized) => normalized,
+        Err(error) => {
+            tracing::warn!(
+                target: "pacquet_resolving_npm_resolver",
+                %error,
+                "could not normalize a non-abbreviated metadata response; keeping the full document",
+            );
+            meta
Evidence
The warning currently logs only %error and a static message, with no package identifier. In the
same function, other error paths include redacted URLs for attribution, so adding at least
meta.name would materially improve diagnostics.

pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata.rs[168-178]
pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata.rs[141-143]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`normalize_abbreviated_meta()` logs a warning on failure but doesn’t include which package was being normalized. That makes the warning much less actionable.

### Issue Context
The code already has access to the package name via `meta.name`; the warning is emitted in a context where adding identifying fields won’t leak secrets.

### Fix Focus Areas
- pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata.rs[168-179]

### Proposed fix
Add structured fields to the `tracing::warn!` call, e.g.:
- `pkg = %meta.name`
Optionally, if you want registry attribution too, pass a redacted URL/registry string down from the caller and include it as `url = %redact_url_credentials(...)`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


8. Changeset contradicts clearMeta 🐞 Bug ⚙ Maintainability
Description
The changeset claims per-version devDependencies are dropped as install-irrelevant, but clearMeta()
explicitly retains devDependencies. This makes the release note misleading about what is actually
removed from cached metadata.
Code

.changeset/normalize-registry-metadata-at-network-layer.md[6]

+Sped up resolution and reduced memory use against registries that do not implement npm's abbreviated metadata format (for example, Azure DevOps Artifacts). Such registries ignore the `application/vnd.npm.install-v1+json` request and return the full package document — including per-version fields the installer never reads (`scripts`, `exports`, `devDependencies`, custom `package.json` fields, etc.). pnpm now detects this at the point of fetching (via the response `Content-Type`) and normalizes the document down to the abbreviated field set before it enters the cache, so subsequent resolutions read and parse a much smaller document. Registries that honor the abbreviated header (such as the npm registry) are detected as already-abbreviated and pay no extra cost. On a large workspace whose feed serves full documents, this roughly halved `pnpm dedupe --offline` time and cut peak memory, with no change to resolution output.
Evidence
The changeset explicitly lists devDependencies among dropped fields, while clearMeta’s pick-list
includes 'devDependencies', so the release note does not match implemented behavior.

.changeset/normalize-registry-metadata-at-network-layer.md[1-6]
pnpm11/resolving/npm-resolver/src/clearMeta.ts[18-44]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The changeset text states that the full document includes install-irrelevant fields that are dropped, explicitly listing `devDependencies`. However, `clearMeta()` currently retains `devDependencies`, so the changeset overstates what is stripped.
### Issue Context
This is a documentation/release-note accuracy issue, not a runtime bug, but it can confuse future perf investigations and user expectations.
### How to fix
Update the changeset wording to remove `devDependencies` from the list of dropped fields (or rephrase to avoid claiming that `devDependencies` is removed).
### Fix Focus Areas
- .changeset/normalize-registry-metadata-at-network-layer.md[6-6]
- pnpm11/resolving/npm-resolver/src/clearMeta.ts[23-31]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
.changeset/normalize-registry-metadata-at-network-layer.md (1)

6-6: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Trim implementation rationale from the user-facing changeset.

The entry explains how the fix works (Content-Type detection, "at the point of fetching," etc.) rather than only what changed for users. Per REVIEW_GUIDE.md, changesets should be "written for users (no implementation rationale)."

✏️ Suggested trim
-Sped up resolution and reduced memory use against registries that do not implement npm's abbreviated metadata format (for example, Azure DevOps Artifacts). Such registries ignore the `application/vnd.npm.install-v1+json` request and return the full package document — including per-version fields the installer never reads (`scripts`, `exports`, `devDependencies`, custom `package.json` fields, etc.). pnpm now detects this at the point of fetching (via the response `Content-Type`) and normalizes the document down to the abbreviated field set before it enters the cache, so subsequent resolutions read and parse a much smaller document. Registries that honor the abbreviated header (such as the npm registry) are detected as already-abbreviated and pay no extra cost. On a large workspace whose feed serves full documents, this roughly halved `pnpm dedupe --offline` time and cut peak memory, with no change to resolution output.
+Reduced memory use and sped up resolution/install against registries that return full (non-abbreviated) package metadata instead of npm's abbreviated format (for example, Azure DevOps Artifacts). Resolution output is unchanged.

As per path instructions, "require an accurate changeset written for users (no implementation rationale) and 'smallest correct version' scope discipline."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.changeset/normalize-registry-metadata-at-network-layer.md at line 6,
Rewrite the changeset text to be user-facing only by removing implementation
details like Content-Type detection, fetching internals, cache normalization,
and parse/path specifics. Keep the summary focused on the observable change for
users—pnpm now handles registries that return full package documents more
efficiently, reducing resolution time and memory use, while preserving the same
resolution output. Reference the existing changeset description and keep it to
the smallest correct version scope.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pnpm11/resolving/npm-resolver/src/clearMeta.ts`:
- Around line 20-44: Hoist the invariant field-list array used by clearMeta out
of the Object.entries(pkg.versions ?? {}) loop so it’s created once instead of
on every iteration. Define the constant near clearMeta and reuse it in the
pick(...) call inside the per-version processing, keeping the behavior the same
while avoiding repeated allocation.

---

Nitpick comments:
In @.changeset/normalize-registry-metadata-at-network-layer.md:
- Line 6: Rewrite the changeset text to be user-facing only by removing
implementation details like Content-Type detection, fetching internals, cache
normalization, and parse/path specifics. Keep the summary focused on the
observable change for users—pnpm now handles registries that return full package
documents more efficiently, reducing resolution time and memory use, while
preserving the same resolution output. Reference the existing changeset
description and keep it to the smallest correct version scope.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 08762627-caf3-4ab8-bfcc-de9b09304759

📥 Commits

Reviewing files that changed from the base of the PR and between 991405e and a9532b1.

📒 Files selected for processing (5)
  • .changeset/normalize-registry-metadata-at-network-layer.md
  • pnpm11/resolving/npm-resolver/src/clearMeta.ts
  • pnpm11/resolving/npm-resolver/src/fetch.ts
  • pnpm11/resolving/npm-resolver/src/pickPackage.ts
  • pnpm11/resolving/npm-resolver/test/normalizeAbbreviated.test.ts

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit a9532b1

…e network layer

pnpm requests abbreviated package metadata (Accept:
application/vnd.npm.install-v1+json). Some registries (e.g. Azure DevOps
Artifacts) ignore that header and return the full CouchDB document, including
per-version fields the installer never reads (scripts, exports,
devDependencies, readme, custom package.json fields). pnpm stored that response
verbatim in the abbreviated metadata cache, so every later resolution re-read
and re-parsed those unused fields — on a large workspace whose feed serves full
documents, a single package's metadata was ~40 MB, ~88% of it unused.

Fix the response at the boundary where it enters pnpm: fetchMetadataFromFromRegistry
inspects the response Content-Type. When an abbreviated request comes back with
anything other than application/vnd.npm.install-v1+json, the registry ignored
the header and served the full document, so the fetch layer strips it to the
abbreviated field set (via the existing clearMeta helper) and re-serializes.
Registries that honor the header (the npm registry echoes the abbreviated
Content-Type) are detected as already-abbreviated and take an early return: no
clearMeta, no re-serialization — the happy path pays nothing.

clearMeta is extracted from pickPackage.ts into its own module so the network
layer can use it without a circular import, and is made null-safe on versions
so it can run on an unpublished package. pickPackage's abbreviated slot no
longer needs any special-casing: the fetch layer now guarantees abbreviated
shape, so the resolver keeps only its pre-existing filterMetadata (full-slot)
narrowing.

This is an alternative to pnpm#12766, which applied the same normalization
one layer up in pickPackage. Both produce a byte-identical on-disk cache and
byte-identical resolution output; this variant additionally skips the work
entirely for spec-compliant registries and removes the special-casing from the
resolver.

Co-authored-by: Copilot <[email protected]>
@zkochan
zkochan force-pushed the ansteg/normalize-registry-metadata-at-network-layer branch from a9532b1 to 14c6ed1 Compare July 4, 2026 11:40
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 14c6ed1

1 similar comment
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 14c6ed1

zkochan added 2 commits July 4, 2026 15:32
- Parse the response Content-Type into its media type (parameters
  dropped, case-insensitive per RFC 9110) instead of a case-sensitive
  substring match, so non-canonical casings and lookalike media types
  are classified correctly.
- Build the normalized versions map with a null prototype so a
  registry-controlled version key named __proto__ cannot mutate the
  map's prototype at the fetch boundary.
- Hoist the invariant abbreviated-field list out of the per-version
  loop.
- Fix the changeset: devDependencies is kept (it is part of the
  abbreviated field set), and trim implementation rationale from the
  user-facing note.
Port of the TypeScript-side change in this PR. Both metadata fetchers
now inspect the response Content-Type: when an abbreviated request
comes back with anything other than
application/vnd.npm.install-v1+json (media type parsed parameter-free
and case-insensitively), the registry ignored the Accept header and
served the full document, so the packument is stripped to the
abbreviated field set via the existing clear_meta before it reaches
the pick or the on-disk mirror. Registries that honor the header skip
the normalization entirely.

clear_meta failure (practically unreachable: the fragments were just
parsed from the response body) keeps the full document instead of
failing the fetch, matching the TypeScript side where normalization
cannot fail.
Copilot AI review requested due to automatic review settings July 4, 2026 13:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata_cached/tests.rs (1)

141-142: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Reuse the existing ACCEPT_ABBREVIATED_DOC constant instead of duplicating the literal.

fetch_full_metadata.rs already exports pub(crate) const ACCEPT_ABBREVIATED_DOC with this exact value. Redefining it here risks drift if the header value changes later (the test would silently stop reflecting the real request header).

♻️ Proposed fix
-const ACCEPT_ABBREVIATED: &str =
-    "application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*";
+use crate::fetch_full_metadata::ACCEPT_ABBREVIATED_DOC as ACCEPT_ABBREVIATED;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata_cached/tests.rs`
around lines 141 - 142, The test is duplicating the abbreviated Accept header
literal instead of reusing the shared constant. Update the
`fetch_full_metadata_cached/tests.rs` test setup to reference
`ACCEPT_ABBREVIATED_DOC` from `fetch_full_metadata.rs` instead of defining
`ACCEPT_ABBREVIATED` locally, so the test always matches the वास्तविक request
header value and stays in sync with future changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata_cached/tests.rs`:
- Around line 141-142: The test is duplicating the abbreviated Accept header
literal instead of reusing the shared constant. Update the
`fetch_full_metadata_cached/tests.rs` test setup to reference
`ACCEPT_ABBREVIATED_DOC` from `fetch_full_metadata.rs` instead of defining
`ACCEPT_ABBREVIATED` locally, so the test always matches the वास्तविक request
header value and stays in sync with future changes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 770a4a61-1de7-4d88-8000-35d49e758e4d

📥 Commits

Reviewing files that changed from the base of the PR and between 14c6ed1 and 65c9bd8.

📒 Files selected for processing (7)
  • .changeset/normalize-registry-metadata-at-network-layer.md
  • pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata.rs
  • pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata_cached.rs
  • pacquet/crates/resolving-npm-resolver/src/fetch_full_metadata_cached/tests.rs
  • pnpm11/resolving/npm-resolver/src/clearMeta.ts
  • pnpm11/resolving/npm-resolver/src/fetch.ts
  • pnpm11/resolving/npm-resolver/test/normalizeAbbreviated.test.ts
✅ Files skipped from review due to trivial changes (1)
  • .changeset/normalize-registry-metadata-at-network-layer.md
🚧 Files skipped from review as they are similar to previous changes (3)
  • pnpm11/resolving/npm-resolver/src/fetch.ts
  • pnpm11/resolving/npm-resolver/src/clearMeta.ts
  • pnpm11/resolving/npm-resolver/test/normalizeAbbreviated.test.ts

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jul 4, 2026
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 65c9bd8

@codecov-commenter

codecov-commenter commented Jul 4, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.02%. Comparing base (ebb4096) to head (43635c9).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
.../resolving-npm-resolver/src/fetch_full_metadata.rs 85.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12772      +/-   ##
==========================================
+ Coverage   84.99%   85.02%   +0.02%     
==========================================
  Files         414      415       +1     
  Lines       65282    65415     +133     
==========================================
+ Hits        55489    55617     +128     
- Misses       9793     9798       +5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 65c9bd8

@github-actions

github-actions Bot commented Jul 4, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: 43635c902e19

Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD.

Scenario: Isolated linker: fresh restore, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.069 ± 0.168 3.858 4.357 1.94 ± 0.17
pacquet@main 4.071 ± 0.137 3.870 4.265 1.94 ± 0.16
pnpr@HEAD 2.097 ± 0.158 1.908 2.320 1.00
pnpr@main 2.161 ± 0.116 1.965 2.300 1.03 ± 0.10
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.06870175618,
      "stddev": 0.1678480695023765,
      "median": 4.06479394978,
      "user": 3.9256287999999997,
      "system": 3.3932914600000004,
      "min": 3.85757846178,
      "max": 4.35717395078,
      "times": [
        4.35717395078,
        4.19221507478,
        3.89673680978,
        4.08725062078,
        4.145516446779999,
        3.99651609578,
        4.24085871178,
        3.85757846178,
        3.87083411078,
        4.04233727878
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.070505068779999,
      "stddev": 0.13652999533398397,
      "median": 4.03391190128,
      "user": 3.9116412999999994,
      "system": 3.38149526,
      "min": 3.8696204937800003,
      "max": 4.26488259878,
      "times": [
        4.04453083578,
        4.02329296678,
        3.8696204937800003,
        3.9154980597800004,
        3.98881427978,
        4.18094363878,
        4.00909019978,
        4.15775944678,
        4.26488259878,
        4.25061816778
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.09674673918,
      "stddev": 0.15818357671634042,
      "median": 2.0429353387800004,
      "user": 2.7153593999999996,
      "system": 2.8385818599999997,
      "min": 1.90785790578,
      "max": 2.32019998778,
      "times": [
        2.2068043097800003,
        2.2313004647800003,
        1.91990788578,
        1.90785790578,
        2.31544557478,
        2.0187288167800004,
        2.03747698478,
        1.96135176878,
        2.0483936927800004,
        2.32019998778
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.16126596618,
      "stddev": 0.11646853325196926,
      "median": 2.20655026328,
      "user": 2.6943561,
      "system": 2.8507574599999996,
      "min": 1.9652364557800002,
      "max": 2.3001151867800003,
      "times": [
        2.09941191578,
        2.18965585178,
        2.01412584978,
        1.9652364557800002,
        2.2396771607800003,
        2.22344467478,
        2.24575301178,
        2.0654871057800004,
        2.3001151867800003,
        2.2697524487800003
      ]
    }
  ]
}

Scenario: Isolated linker: fresh restore, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 665.8 ± 13.4 644.9 689.0 1.00
pacquet@main 670.6 ± 67.6 623.1 856.4 1.01 ± 0.10
pnpr@HEAD 715.5 ± 50.0 692.5 856.9 1.07 ± 0.08
pnpr@main 695.1 ± 27.4 663.6 749.0 1.04 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.66584977532,
      "stddev": 0.013364388506212315,
      "median": 0.66496444432,
      "user": 0.38870515999999994,
      "system": 1.3436678999999998,
      "min": 0.64490745182,
      "max": 0.68896531482,
      "times": [
        0.66507673082,
        0.66357188582,
        0.65068339282,
        0.67428524482,
        0.66485215782,
        0.68896531482,
        0.67554116982,
        0.65453494582,
        0.64490745182,
        0.67607945882
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.67058704272,
      "stddev": 0.06764822297709437,
      "median": 0.64960527332,
      "user": 0.37581455999999996,
      "system": 1.3240945999999998,
      "min": 0.62306306582,
      "max": 0.85635038682,
      "times": [
        0.65657300482,
        0.65484990882,
        0.64020313082,
        0.63695213682,
        0.65192677082,
        0.64667288982,
        0.64728377582,
        0.62306306582,
        0.85635038682,
        0.69199535682
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.71552215112,
      "stddev": 0.05003662686726339,
      "median": 0.7017814153199999,
      "user": 0.40750975999999994,
      "system": 1.3567831,
      "min": 0.69246443882,
      "max": 0.8568957928200001,
      "times": [
        0.70462067582,
        0.69366544182,
        0.70035327882,
        0.69394627382,
        0.70320955182,
        0.69246443882,
        0.69449291582,
        0.8568957928200001,
        0.70992353982,
        0.70564960182
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.69511930442,
      "stddev": 0.027418812121846898,
      "median": 0.69292727832,
      "user": 0.38516155999999996,
      "system": 1.3427025999999997,
      "min": 0.66356187282,
      "max": 0.74898203282,
      "times": [
        0.68462913682,
        0.71867495782,
        0.67045344082,
        0.66356187282,
        0.67492874982,
        0.71289496482,
        0.74898203282,
        0.70122541982,
        0.70704186982,
        0.66880059882
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.240 ± 0.028 4.194 4.284 2.01 ± 0.11
pacquet@main 4.218 ± 0.031 4.175 4.248 2.00 ± 0.11
pnpr@HEAD 2.114 ± 0.111 1.956 2.326 1.00
pnpr@main 2.117 ± 0.091 2.008 2.261 1.00 ± 0.07
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.239982040159999,
      "stddev": 0.027942125134977697,
      "median": 4.242582693459999,
      "user": 3.8442624600000004,
      "system": 3.29251472,
      "min": 4.193986767459999,
      "max": 4.28419586046,
      "times": [
        4.25570130446,
        4.2712556054599995,
        4.250184916459999,
        4.193986767459999,
        4.28419586046,
        4.23085510546,
        4.204148389459999,
        4.22432706546,
        4.24179279846,
        4.24337258846
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.21821854756,
      "stddev": 0.030947384021691463,
      "median": 4.236202261459999,
      "user": 3.80276956,
      "system": 3.310076719999999,
      "min": 4.17539239146,
      "max": 4.24840879846,
      "times": [
        4.24840879846,
        4.18874577146,
        4.187522127459999,
        4.24061380746,
        4.24630996446,
        4.17539239146,
        4.2334861534599995,
        4.24315734346,
        4.179630748459999,
        4.2389183694599994
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.11370555146,
      "stddev": 0.11121924809298235,
      "median": 2.09166636046,
      "user": 2.57234886,
      "system": 2.78514092,
      "min": 1.9561703814600002,
      "max": 2.32643509146,
      "times": [
        2.10600945846,
        2.07476866846,
        2.07732326246,
        1.9561703814600002,
        2.05471814546,
        2.32643509146,
        2.02191573446,
        2.11535251746,
        2.27564496046,
        2.12871729446
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.11738809296,
      "stddev": 0.09134154489574722,
      "median": 2.08759736396,
      "user": 2.56287486,
      "system": 2.78596282,
      "min": 2.00838789946,
      "max": 2.26115126646,
      "times": [
        2.1812208274600002,
        2.00838789946,
        2.02390665146,
        2.06441660346,
        2.17250064546,
        2.26115126646,
        2.04293525646,
        2.2441670514600003,
        2.07190128346,
        2.10329344446
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, hot cache + hot store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.380 ± 0.026 1.357 1.450 2.11 ± 0.04
pacquet@main 1.373 ± 0.034 1.341 1.465 2.10 ± 0.06
pnpr@HEAD 0.704 ± 0.105 0.658 1.001 1.08 ± 0.16
pnpr@main 0.654 ± 0.006 0.645 0.664 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.37986330364,
      "stddev": 0.025646325138347432,
      "median": 1.3750087741400001,
      "user": 1.3767934399999997,
      "system": 1.6876349799999997,
      "min": 1.3568799686400002,
      "max": 1.4504450716400001,
      "times": [
        1.37782409064,
        1.3682705156400001,
        1.37022919664,
        1.37659675564,
        1.37346870464,
        1.3765488436400002,
        1.3568799686400002,
        1.4504450716400001,
        1.37924383464,
        1.3691260546400001
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.37299690984,
      "stddev": 0.0343740810114423,
      "median": 1.36345217414,
      "user": 1.32575654,
      "system": 1.69800788,
      "min": 1.3411207316400002,
      "max": 1.4647601196400002,
      "times": [
        1.3806927586400002,
        1.4647601196400002,
        1.35985686164,
        1.35068742764,
        1.37824255664,
        1.35711995064,
        1.37058434364,
        1.36300464264,
        1.3411207316400002,
        1.3638997056400002
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.70390904654,
      "stddev": 0.10483631782845625,
      "median": 0.67180985414,
      "user": 0.36700654,
      "system": 1.28624828,
      "min": 0.65816152264,
      "max": 1.00103629564,
      "times": [
        0.65816152264,
        0.66841232364,
        0.66170985464,
        1.00103629564,
        0.67153684564,
        0.68602756664,
        0.65978929264,
        0.6720828626400001,
        0.67552394664,
        0.68480995464
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.6541494863399999,
      "stddev": 0.005881101036171655,
      "median": 0.65396859964,
      "user": 0.33475794,
      "system": 1.2723747799999998,
      "min": 0.64481522864,
      "max": 0.6636996376400001,
      "times": [
        0.65111162664,
        0.64481522864,
        0.64786951464,
        0.65221875464,
        0.65032394064,
        0.65699205264,
        0.66001108764,
        0.6636996376400001,
        0.6557184446400001,
        0.65873457564
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + hot store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 3.042 ± 0.028 3.012 3.106 4.56 ± 0.06
pacquet@main 3.028 ± 0.026 2.999 3.087 4.53 ± 0.06
pnpr@HEAD 0.668 ± 0.007 0.656 0.675 1.00
pnpr@main 0.682 ± 0.007 0.672 0.696 1.02 ± 0.02
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 3.042018579319999,
      "stddev": 0.028240401010207708,
      "median": 3.0353802216199997,
      "user": 1.81313608,
      "system": 1.98282822,
      "min": 3.01188324362,
      "max": 3.10647073462,
      "times": [
        3.10647073462,
        3.01188324362,
        3.0165069936199997,
        3.03504904362,
        3.0494716286199997,
        3.05929581762,
        3.0321671636199996,
        3.0159461356199997,
        3.05768363262,
        3.03571139962
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 3.0283727579199997,
      "stddev": 0.02602570215120123,
      "median": 3.02170381062,
      "user": 1.7756555799999998,
      "system": 1.97988792,
      "min": 2.99915475062,
      "max": 3.0865912066199996,
      "times": [
        3.01253131862,
        3.02378235662,
        3.0196252646199997,
        3.0050466646199996,
        2.99915475062,
        3.0141939336199997,
        3.0298935006199996,
        3.0536331196199997,
        3.0865912066199996,
        3.0392754636199997
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.6677956345199999,
      "stddev": 0.00721404267549917,
      "median": 0.6688989911200001,
      "user": 0.35222838,
      "system": 1.28894362,
      "min": 0.65624726862,
      "max": 0.67540303962,
      "times": [
        0.6745855376200001,
        0.6610936916200001,
        0.6678264756200001,
        0.65731615862,
        0.67540303962,
        0.6691882076200001,
        0.6743720066200001,
        0.65624726862,
        0.67331418462,
        0.66860977462
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.6818356108200001,
      "stddev": 0.007324943389202568,
      "median": 0.6818457186200001,
      "user": 0.33958678,
      "system": 1.29594712,
      "min": 0.6717955026200001,
      "max": 0.6959349316200001,
      "times": [
        0.6959349316200001,
        0.6897517966200001,
        0.6813212366200001,
        0.6823702006200001,
        0.6774218806200001,
        0.6717955026200001,
        0.6792577026200001,
        0.6826299666200001,
        0.6851216786200001,
        0.6727512116200001
      ]
    }
  ]
}

Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 6.743 ± 0.141 6.606 7.057 1.38 ± 0.04
pacquet@main 6.802 ± 0.165 6.617 7.033 1.40 ± 0.04
pnpr@HEAD 4.869 ± 0.082 4.691 4.978 1.00
pnpr@main 4.884 ± 0.063 4.787 4.954 1.00 ± 0.02
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 6.74322498868,
      "stddev": 0.14146880079545712,
      "median": 6.71617000958,
      "user": 4.099998459999999,
      "system": 3.6637893399999997,
      "min": 6.60590011508,
      "max": 7.057132656079999,
      "times": [
        7.057132656079999,
        6.7165855810799995,
        6.6219784940799995,
        6.71819628308,
        6.66334439408,
        6.84261132708,
        6.623583669079999,
        6.86716292908,
        6.60590011508,
        6.71575443808
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 6.8015794106800005,
      "stddev": 0.16528004906318616,
      "median": 6.760843449579999,
      "user": 4.104333459999999,
      "system": 3.6260417400000002,
      "min": 6.61722612308,
      "max": 7.03336209308,
      "times": [
        6.98975653308,
        6.8262442950799995,
        6.61722612308,
        6.65670618808,
        7.01689245208,
        6.85909915708,
        6.67500751908,
        6.64605714208,
        7.03336209308,
        6.69544260408
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 4.868962460180001,
      "stddev": 0.08223482811921691,
      "median": 4.8731005110800005,
      "user": 2.8427282600000003,
      "system": 3.1069894400000004,
      "min": 4.690942415079999,
      "max": 4.97825430608,
      "times": [
        4.9489153010799996,
        4.88484671408,
        4.93947017208,
        4.85105453908,
        4.87967143908,
        4.85045730408,
        4.86652958308,
        4.97825430608,
        4.690942415079999,
        4.7994828280799995
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 4.88445890278,
      "stddev": 0.06308686374226721,
      "median": 4.89140664558,
      "user": 2.8093123600000003,
      "system": 3.1148537400000005,
      "min": 4.78658556108,
      "max": 4.95418071408,
      "times": [
        4.79829414208,
        4.84851380708,
        4.94819927808,
        4.93947004208,
        4.84229565408,
        4.88346545108,
        4.95418071408,
        4.94423653808,
        4.89934784008,
        4.78658556108
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Jul 4, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12772
Testbedpacquet
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
🚷 view threshold
4,239.98 ms
(-1.52%)Baseline: 4,305.53 ms
5,166.63 ms
(82.06%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
3,042.02 ms
(-0.32%)Baseline: 3,051.77 ms
3,662.12 ms
(83.07%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
1,379.86 ms
(+1.80%)Baseline: 1,355.44 ms
1,626.53 ms
(84.83%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
4,068.70 ms
(-1.66%)Baseline: 4,137.59 ms
4,965.10 ms
(81.95%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
6,743.22 ms
(-3.20%)Baseline: 6,966.45 ms
8,359.75 ms
(80.66%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
665.85 ms
(+6.21%)Baseline: 626.94 ms
752.33 ms
(88.50%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

github-actions Bot commented Jul 4, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12772
Testbedpnpr

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds flag.

Click to view all benchmark results
BenchmarkLatencymilliseconds (ms)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
2,113.71 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
667.80 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
703.91 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
2,096.75 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
4,868.96 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
715.52 ms
🐰 View full continuous benchmarking report in Bencher

…s against drift

ACCEPT_ABBREVIATED_DOC and ABBREVIATED_META_CONTENT_TYPE repeat the
abbreviated media type as separate literals because Rust cannot build
one string const from another without a macro or an extra dependency.
Assert that the Accept header offers the media type the response
detection recognizes, so an edit to either constant alone fails loudly.
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 43635c9

1 similar comment
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 43635c9

@zkochan
zkochan enabled auto-merge July 4, 2026 14:34
@zkochan
zkochan disabled auto-merge July 4, 2026 15:00
@zkochan
zkochan merged commit 99982b9 into pnpm:main Jul 4, 2026
33 checks passed
@welcome

welcome Bot commented Jul 4, 2026

Copy link
Copy Markdown

Congrats on merging your first pull request! 🎉🎉🎉

@astegmaier

Copy link
Copy Markdown
Contributor Author

Thanks @zkochan for reviewing and merging this so quickly! I know that with AI writing code is much easier than reviewing, and I appreciate you doing the hard part :-)

This and #12760 combined result in 5x seepedup in dedupe for our large monorepo at Microsoft - effectively unblocking us from migrating our repo to pnpm. That's a huge win for us.

@zkochan

zkochan commented Jul 4, 2026

Copy link
Copy Markdown
Member

Nice! If you want further speed improvement, you can check pnpr. It is experimental yet but with server side resolution it makes resolution 2 times faster even compared to the rust rewrite of pnpm.

@zkochan

zkochan commented Jul 4, 2026 •

Copy link
Copy Markdown
Member

also, interestingly pnpr was also solving this issue out of the box already. If you would request Azure DevOps via a pnpr registry, it would automatically filter the full metadata.

@astegmaier

Copy link
Copy Markdown
Contributor Author

If you would request Azure DevOps via a pnpr registry, it would automatically filter the full metadata.

Awesome! I'll take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants