The bug that only appears at midnight
How a daily rollover turned into a monitoring blind spot — and why boundary testing pays for itself.
A support ticket landed one morning. Nothing dramatic — just an observation from a night-shift operator:
“The stream count was zero when I logged in at 12:05 AM. Refreshed, and it was fine.”
Zero. For a night-shift operator, zero streams is the scariest number on the screen. It means either everything has stopped, or the dashboard is lying.
I'd been testing timezone handling that week. 12:05 AM. Just past midnight. Something clicked.
The investigation
I opened the dashboard with an active stream, changed the system clock past midnight, and waited without refreshing. The count dropped to zero within seconds. Reloading brought it back — the actual count, unaffected.
So the backend was fine. The UI was fine. The boundary between them was not.
The stream count came from a rolling 24-hour bucket keyed by date. At midnight, a new bucket started empty — and the query returned that empty bucket instead of falling back to the previous day's total. The dashboard rendered 0 without checking whether the underlying data was actually zero.
It had been in production for months. Nobody caught it because:
- It only appeared between 00:00 and the first new stream of the day — usually under a minute.
- Reloading (the reflex action) fixed it silently.
- Test cycles ran during business hours.
The fix
- Backend: The aggregation query now coalesces an empty bucket to the previous day's count when the new day has no data yet.
- Frontend: The widget subscribes to the rollover event and re-fetches immediately.
- Prevention: A regression test freezes time at 23:59:55, steps forward 10 seconds, and asserts the count never drops to zero mid-transition.
The lesson
Boundary testing is usually taught as “test 0, 1, and the maximum.” That's useful. But it misses the boundaries that matter most in production: boundaries in time, in state transitions, and in data that only exists briefly.
Three questions I now ask before signing off any feature involving time:
- What happens the exact moment this value crosses a boundary?
- Who is awake when that boundary is crossed?
- What does a reasonable user do when the value looks wrong — and does that reflex hide the bug?
The midnight defect wasn't hard to fix. It was hard to notice. That's the job.