The Autosave That Cut You Off

Medium

· Frontend

Incident

SEV-3

Time to fix: 20 min

Failing checks on the shipped build

  • no edits means no save

    nothing changed since the last save: expected condition to hold

  • typing right now blocks the save

    only 500ms since the last keystroke: expected condition to hold

How to work this incident

  1. Read the report: write down the expected behaviour and the actual one in a sentence each.
  2. Reproduce it: run the visible tests and find the failing check that matches the report.
  3. 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.
  4. Follow the value the screen shows back through the state and the pure helpers that compute it; the view is usually only the messenger.
  5. Fix the cause rather than the symptom, run the visible tests again, and submit against the hidden ones — then write the root cause down.

Inspired by

Document editors

Inspired by document editors that save while you're typing — snapshotting half-finished sentences — or save constantly with no edits at all. Autosave should fire only after a quiet period follows an actual edit.

Autosave.java gets the timestamps; the logic is inverted.

Code map

class Autosave {
    static final long QUIET_MS = 2000;

    static boolean shouldSave(long lastSaveMs, long lastEditMs, long nowMs) {
        return nowMs - lastSaveMs >= QUIET_MS;
    }
}

Sign in to edit the file, run the tests and submit a fix

A free account — no card, no trial clock. You come straight back here.

The Autosave That Cut You Off — Java Bug Hunt

Inspired by document editors that save while you're typing — snapshotting half-finished sentences — or save constantly with no edits at all.

  • Language: Java
  • Layer: Frontend
  • Difficulty: Medium
  • Concepts: Debounce, Timers
  • Modelled on: Document editors
  • Visible tests: no edits means no save; typing right now blocks the save; a quiet period after edits saves
  • Reward: 50 XP for a complete fix

Incident

  • Severity: SEV-3
  • Time to fix: 20 minutes, the target for a medium incident

Failing checks on the shipped build

  • no edits means no save — nothing changed since the last save: expected condition to hold
  • typing right now blocks the save — only 500ms since the last keystroke: expected condition to hold

How to work this incident

  1. Read the report: write down the expected behaviour and the actual one in a sentence each.
  2. Reproduce it: run the visible tests and find the failing check that matches the report.
  3. 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.
  4. Follow the value the screen shows back through the state and the pure helpers that compute it; the view is usually only the messenger.
  5. 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 document editors that save while you're typing — snapshotting half-finished sentences — or save constantly with no edits at all. Autosave should fire only after a quiet period follows an actual edit.

Autosave.java gets the timestamps; the logic is inverted.

Bug report

BUG-AUTOSAVE · Reported by: docs team

shouldSave(lastSaveMs, lastEditMs, nowMs) with a 2000ms quiet period:

  • there must BE unsaved edits: lastEditMs > lastSaveMs
  • and the user must have been quiet: nowMs - lastEditMs >= 2000

Observed: it saves every 2s regardless of edits, including mid-keystroke.

Logs

[docs] snapshot saved mid-word: "The quarterly resul"

The code as shipped

Autosave.java (editable)

class Autosave {
    static final long QUIET_MS = 2000;

    static boolean shouldSave(long lastSaveMs, long lastEditMs, long nowMs) {
        return nowMs - lastSaveMs >= QUIET_MS;
    }
}

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 Java bug hunts.