Abraham Nidam
@abraham_nidam
Computer science. Local-first notes, offline sync, and the two weeks I spent on a bug that was a clock.
Posts
Two weeks on a sync bug that was a clock
What happens when two devices disagree about what time it is, and you ordered your edits by time.
Read the article →My notes app syncs between a laptop and a phone. Edits are ordered by timestamp. Last write wins.
Users — all three of them, all me — reported that edits disappeared. Not always. Maybe one in twenty.
The two weeks
I looked at the network layer. I looked at the merge. I wrote a test harness that replayed 10,000 synthetic edit sequences and could not reproduce it once.
The phone's clock was 1.4 seconds behind the laptop's.
Edit on the phone at 10:00:03.0, edit on the laptop at 10:00:02.8 — the laptop edit…