Skip to content

Fix npm dist-tags when cooldown holds back tagged versions - #654

Closed
kokes wants to merge 1 commit into
git-pkgs:mainfrom
kokes:kokes/npm-cooldown-dist-tags
Closed

kokes wants to merge 1 commit into
git-pkgs:mainfrom
kokes:kokes/npm-cooldown-dist-tags

Conversation

@kokes

@kokes kokes commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Problem

When cooldown withholds the version dist-tags.latest points at, npm metadata rewriting moved latest to the remaining version with the newest publish time. That can be:

  • a prerelease (5.0.0-beta.1 becomes latest), or
  • a backport to an older major (a 3.x patch published after 4.17.21 makes latest go from 4.x to 3.x).

Other dist-tags (next, beta, ...) that pointed at withheld versions were left dangling, so npm install pkg@next hit a version that is no longer in versions.

Repro (3d cooldown): latest=4.18.0 (1d old), next=5.0.0-rc.1 (1d old), v3=3.10.2; remaining 4.17.21, 5.0.0-beta.1, 3.10.2. Before: latest=3.10.2, next=5.0.0-rc.1 (removed). After: latest=4.17.21, next dropped, v3 kept.

Change

The denylist path already did this correctly. This moves its tag fix-up into a shared removeDistTags helper and uses it from cooldown too: tags naming a removed version are dropped, and latest moves to the highest remaining stable version (newestStableNPMVersion). updateDistTagsLatest and findNewestVersion are gone.

The streaming rewrite shares applyCooldownFiltering, so it picks this up; TestRewriteStreamMatchesRewrite covers a prerelease-and-backport document.

Behaviour change to review

If cooldown removes latest and only prereleases remain, latest is now dropped (as the denylist already does) instead of moving to the newest prerelease.

Tests

  • TestNPMRewriteMetadataCooldownRetargetsLatest (fails on main)
  • new streamed/in-memory equivalence case
  • go build ./..., go vet, go test ./internal/... pass

🤖 Generated with Claude Code

Cooldown moved latest to the remaining version with the newest publish
time, which could be a prerelease or a backport to an older major, and
left other tags pointing at versions it removed. Share the denylist's
tag handling: tags naming removed versions are dropped, and latest is
moved to the highest remaining stable version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kokes

kokes commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Don't have the bandwidth to re-review this, closing for now.

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