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
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 edit the files, run the visible tests and submit against the hidden ones. More JavaScript bug hunts.