Version 1.10 Beats Version 1.9 — JavaScript Bug Hunt
Inspired by every auto-updater that ever refused to update: comparing version strings as strings makes "1.10.0" sort before "1.9.0", so half the fleet stays…
- Language: JavaScript
- Layer: Backend
- Difficulty: Easy
- Concepts: Versioning, Parsing
- Modelled on: Auto-updaters
- Visible tests: double-digit segments compare numerically; ordinary bumps still register
- Reward: 50 XP for a complete fix
Briefing
Inspired by every auto-updater that ever refused to update: comparing version strings as strings makes "1.10.0" sort before "1.9.0", so half the fleet stays on the old release forever.
semver.js — compare numerically, segment by segment.
Bug report
BUG-VERCMP · Priority: High · Reported by: release eng
isNewer(a, b) — true iff version a is strictly newer than b:
- compare dot-separated segments numerically
- missing segments count as 0 ("2.0" == "2.0.0")
Observed: "1.10.0" is treated as OLDER than "1.9.0"; the updater loops.
Logs
[updater] latest=1.10.0 current=1.9.0 -> "already up to date"The code as shipped
src/release/semver.js (editable)
// Version comparison for the auto-updater.
exports.isNewer = function (a, b) {
return a > b;
};
Open the hunt to edit the files, run the visible tests and submit against the hidden ones. More JavaScript bug hunts.