The ETA That Went Negative — JavaScript Bug Hunt
Inspired by ride-hailing apps showing "-1 min" while your driver waits outside.
- Language: JavaScript
- Layer: Frontend
- Difficulty: Easy
- Concepts: Formatting, Math
- Modelled on: Uber
- Visible tests: under 30 seconds is Arriving now; partial minutes round up; negative time never shows
- Reward: 50 XP for a complete fix
Incident
- Severity: SEV-3
- Time to fix: 10 minutes, the target for an easy incident
Failing checks on the shipped build
- under 30 seconds is Arriving now — expected "Arriving now" but got "0 min"
- partial minutes round up — expected "2 min" but got "1 min"
- negative time never shows — expected "Arriving now" but got "-1 min"
How to work this incident
- Read the report: write down the expected behaviour and the actual one in a sentence each.
- Reproduce it: run the visible tests and find the failing check that matches the report.
- Read the logs and the failing checks for the first value that is wrong — the earliest wrong value is nearer the cause than the loudest error.
- Follow the value the screen shows back through the state and the pure helpers that compute it; the view is usually only the messenger.
- Fix the cause rather than the symptom, run the visible tests again, and submit against the hidden ones — then write the root cause down.
Briefing
Inspired by ride-hailing apps showing "-1 min" while your driver waits outside. The ETA label must never go below "Arriving now", and partial minutes always round up — a driver 61 seconds away is "2 min", not "1 min".
Fix eta.js.
Bug report
BUG-404MIN · Reported by: rider app
formatEta(msRemaining):
- under 30 seconds (including anything negative) -> "Arriving now"
- otherwise ceil to whole minutes -> "N min"
Observed: "0 min" at 20s and "-1 min" after arrival.
Logs
[eta] remaining=-32000 label="-1 min"The code as shipped
src/ride/eta.js (editable)
// Human label for the ride ETA.
exports.formatEta = function (msRemaining) {
var minutes = Math.floor(msRemaining / 60000);
return minutes + " min";
};
Open the hunt to start the incident clock, edit the files, run the visible tests and submit against the hidden ones, then write the root cause down. More JavaScript bug hunts.