Undo Send Never Works — JavaScript Bug Hunt
Inspired by Gmail's Undo Send — and by the unit-mismatch bugs that break features like it.
- Language: JavaScript
- Layer: Frontend
- Difficulty: Easy
- Concepts: Units, Timers
- Modelled on: Gmail
- Visible tests: undo works inside the window; undo expires after the window; the boundary second is inclusive
- Reward: 50 XP for a complete fix
Incident
- Severity: SEV-2 (priority: High)
- Ticket: BUG-CTRL-Z
- Reported by: dogfood
- Time to fix: 10 minutes, the target for an easy incident
Failing checks on the shipped build
- undo works inside the window — 2s after send: expected true but got false
- the boundary second is inclusive — exactly 5s: expected true but got false
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 Gmail's Undo Send — and by the unit-mismatch bugs that break features like it. The undo window is 5 seconds, but the button is dead the instant an email leaves.
One comparison in undoSend.js mixes milliseconds with seconds.
Bug report
BUG-CTRL-Z · Priority: High · Reported by: dogfood
canUndo(sentAtMs, nowMs) with a 5-second window:
- 2s after sending -> must be true
- 6s after sending -> must be false
- exactly 5.000s -> still true (inclusive)
Observed: false even 50ms after sending.
Logs
[undo] sentAt=1700000000000 now=1700000000050 canUndo=false (?!)The code as shipped
src/mail/undoSend.js (editable)
// The undo-send grace window.
var WINDOW_SECONDS = 5;
exports.canUndo = function (sentAtMs, nowMs) {
return nowMs - sentAtMs <= WINDOW_SECONDS;
};
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.