Skip to content

fix(npm-resolver): minimumReleaseAge handling for cached abbreviated metadata (release/10)#11630

Merged
zkochan merged 1 commit into
release/10from
cherry-pick/npm-resolver-min-release-age-cached-abbreviated-release-10
May 14, 2026
Merged

fix(npm-resolver): minimumReleaseAge handling for cached abbreviated metadata (release/10)#11630
zkochan merged 1 commit into
release/10from
cherry-pick/npm-resolver-min-release-age-cached-abbreviated-release-10

Conversation

@zkochan

@zkochan zkochan commented May 14, 2026

Copy link
Copy Markdown
Member

Summary

Backport of #11622 to release/10.

The npm registry returns abbreviated package metadata (without per-version time) by default. Whenever pnpm reused cached abbreviated metadata under minimumReleaseAge / publishedBy, pickPackageFromMeta would throw ERR_PNPM_MISSING_TIME because the maturity check needs time to run.

This PR makes pnpm upgrade cached abbreviated metadata to the full document via a follow-up fetch whenever publishedBy is active and the cached meta lacks time:

  • In-memory cache hit
  • Disk cache hit (offline / preferOffline / pickLowestVersion paths)
  • Initial fetch that returns abbreviated metadata

The upgraded full metadata is persisted to the on-disk cache so subsequent installs skip the extra fetch. The version-spec cache fast path also now lets ERR_PNPM_MISSING_TIME fall through to the network fetch even under strictPublishedByCheck, since the fetch can supply real time data.

Differences from main

The original commit (e526f89 on main) sits on top of refactors that don't exist on release/10:

  • No FetchMetadataResult/304 plumbing — ctx.fetch returns PackageMeta directly, so the 304-specific branch is omitted.
  • No pickMatchingVersionFast/pickMatchingVersionFinal split — release/10 uses a single _pickPackageFromMeta.
  • No prepareJsonForDisk / .jsonl cache format — release/10 writes plain JSON.
  • No modified-based gating — release/10's PackageMeta lacks the modified field, so the helper triggers the upgrade whenever cached meta lacks time (correctness over saving a network call).

Test plan

  • pnpm --filter @pnpm/npm-resolver run compile (lint + tsc) clean
  • pnpm --filter @pnpm/npm-resolver test — all 135 tests pass, including 3 new ones in publishedBy.test.ts:
    • re-fetch full metadata when registry returns abbreviated metadata and publishedBy is set
    • upgrade disk-cached abbreviated metadata to full when publishedBy is set
    • strictPublishedByCheck=true does not rethrow ERR_PNPM_MISSING_TIME from the version-spec cache path

Written by an agent (Claude Code, claude-opus-4-7).

…metadata

Backport of #11622 to release/10. The npm registry returns abbreviated
package metadata (without per-version `time`) by default, which made the
maturity check throw ERR_PNPM_MISSING_TIME whenever cached abbreviated
metadata was reused under `publishedBy`/`minimumReleaseAge`. pnpm now
upgrades cached abbreviated metadata to the full document via a follow-up
fetch, persists the upgrade to the on-disk cache so subsequent installs
skip the extra fetch, and lets ERR_PNPM_MISSING_TIME from the cache fast
path fall through to the network fetch even under strict mode.

Adapted to release/10's simpler pickPackage shape (no 304/etag plumbing,
no `pickMatchingVersionFast`/`pickMatchingVersionFinal` split, no
`ignoreMissingTimeField`), so the unconditional helper triggers the
upgrade whenever the cached meta lacks `time`.
@coderabbitai

coderabbitai Bot commented May 14, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d4f7c724-053c-4d5e-8515-4710cbc8db4c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cherry-pick/npm-resolver-min-release-age-cached-abbreviated-release-10

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

@zkochan zkochan merged commit 4a04433 into release/10 May 14, 2026
13 of 14 checks passed
@zkochan zkochan deleted the cherry-pick/npm-resolver-min-release-age-cached-abbreviated-release-10 branch May 14, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant