The Infinite Spinner — JavaScript Bug Hunt
Inspired by the most-screenshotted bug in any app: the spinner that never stops. The loading flag is cleared on success — and only on success.
- Language: JavaScript
- Layer: Frontend
- Difficulty: Easy
- Concepts: State, Error Handling
- Modelled on: Every SPA
- Visible tests: errors stop the spinner; success stores the data
- 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
- errors stop the spinner — spinner must stop on failure: expected false but got true
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 the most-screenshotted bug in any app: the spinner that never stops. The loading flag is cleared on success — and only on success. One failed request and the UI spins until a refresh.
loading.js folds request lifecycle events.
Bug report
BUG-SPINNER · Reported by: support (screenshot supply is infinite)
reduce(state, event) — events: start / success / error:
- start -> loading true, error null
- success -> loading false, data set
- error -> loading FALSE, error message set
Observed: the error branch forgets the flag; failed dashboards spin forever.
Logs
[ui] request failed; isLoading still true 45 minutes laterThe code as shipped
src/ui/loading.js (editable)
// Request lifecycle reducer.
exports.reduce = function (state, event) {
if (event.type === "start") {
return { loading: true, data: state.data, error: null };
}
if (event.type === "success") {
return { loading: false, data: event.data, error: null };
}
if (event.type === "error") {
return { loading: state.loading, data: state.data, error: event.message };
}
return state;
};
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.