fix(semver): keep prerelease when comparing versions - #7
Merged
Conversation
semver.coerce() drops the prerelease, so every 1.0.0-beta.N coerced to 1.0.0 and compared equal. persistRelease only bumps latestVersion when compareSemver(new, current) > 0, so a plugin's latestVersion froze at whichever prerelease of a series landed first while later betas kept ingesting as ordinary release rows. Live effect on the postgresql plugin: latestVersion stuck at 1.0.0-beta.5 with beta.6 and beta.7 published. The detail page sorts releases by createdAt and showed beta.7 next to the download button, but /api/plugins/:slug/latest resolves through latestVersion and served beta.5 binaries — same path the desktop client uses to install and update. Same bug ranked a stable 2.0.0 equal to its own 2.0.0-rc.1. compareSemver had no test coverage at all; added a block that fails on both counts without the fix.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
This was referenced Aug 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reported on Discord: the PostgreSQL plugin page shows
beta.5as the latest release whilebeta.7is published and also visible on the page.Root cause
compareSemvercoerced both sides withsemver.coerce(), which drops the prerelease. Every1.0.0-beta.Ncollapsed to1.0.0, so they all compared equal.persistReleaseonly bumpslatestVersionwhencompareSemver(new, current) > 0, so once a prerelease series started,latestVersionfroze at whichever beta landed first — later betas kept ingesting as normal release rows, which is why both versions appear on the page.The same bug ranked a stable
2.0.0equal to its own2.0.0-rc.1, so a GA release would not have replaced its release candidate as latest either.Not just cosmetic
The plugin detail page sorts releases by
createdAtfor the download section (beta.7), but the download button links to/api/plugins/:slug/latest, which resolves throughlatestVersion. Verified against production: that endpoint returns asset URLs under/download/v1.0.0-beta.5/. The desktop client uses the same endpoint for install and update, so users were gettingbeta.5while the page advertisedbeta.7.Fix
semver.coerce(x, { includePrerelease: true }). Thecoerce()call is still needed for legacy lax tags (v1.2), and those keep working.compareSemverhad no test coverage at all, which is how this shipped. Added a block covering prerelease ordering, stable-vs-own-prerelease, plain releases, legacy lax tags, and unparseable input — verified it fails on exactly the two prerelease cases without the fix.After merge
Deploying only fixes future ingests; the stored
latestVersionforpostgresqlstays wrong. Repairing it needs no SQL — Admin → Plugins → postgresql → Replay webhook re-runspersistReleaseagainst the upstream latest release, which then passes the corrected comparison and writes1.0.0-beta.7.Scanned all 13 plugins on the production registry:
postgresqlis the only one currently mismatched, since it is the only one publishing prereleases.