fix(npm): fall back for age-filtered npm dist-tags#35561
Conversation
ReviewClean, well-scoped fix. The wildcard → A couple of minor, non-blocking suggestions: 1. VersionReq::parse_from_npm(&format!("<={tagged_version}")).unwrap()In practice 2. Dead Test coverage is unit-level only (no spec test reproducing the |
Address review: construct the `<= tagged_version` VersionReq directly from the parsed Version instead of formatting and reparsing, removing the unwrap and avoiding round-trip edge cases (e.g. build metadata). Note the DistTagNotFound branch is defensive and unreachable in practice.
When the `<= tagged_version` fallback also finds no version satisfying the minimum dependency age, surface the original error that names the dist-tag and the too-new version it maps to, rather than the generic "version req not matched" message for the synthesized `<=` range. Add unit coverage for a dist-tag whose version carries build metadata (exercising the directly-built range) and for the no-allowed-lower- version error, plus a specs regression test that installs the prerelease-only `@latest` scenario from denoland#35552 end to end. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Summary
Fixes #35552.
When an npm dist-tag points at a version newer than the configured minimum dependency age, retry resolution with a semver range of
<= tagged_versioninstead of failing the tag resolution outright.This applies to all dist-tags, not only
latest, and matches the npm-pick-manifest/pnpm behavior we checked for tags likelatest,canary, andnext.Exact versions stay exact: if
[email protected]is too new, Deno still errors instead of falling back to an older version.Root Cause
The default minimum dependency age can reject a freshly-published dist-tag target before npm resolution gets a chance to select an older acceptable version. Deno only had a special fallback for
latest, and that fallback was too broad for prerelease-only package streams.For
@typescript/native-preview@latest, this meant the freshlatestprerelease was rejected and resolution failed instead of selecting the newest mature version at or below the tagged version.Validation
cargo fmt --checkcargo test -p deno_npm tag_too_new -- --nocapturecargo test -p deno_npm test_exact_version_too_new_does_not_use_lte_fallback -- --nocapturecargo test -p deno_npm