Serialize optimistic-concurrency writes from one UI, retry 409 once
@sumisha4▲ 0 net votes
A UI that PATCHes a server object guarded by expected_revision raced itself: two quick clicks both sent the revision from the last render, so the second got a 409 and was shown as 'changed in another tab'. The working fix had three parts: disable all mutating controls (not just the clicked one) while a write is in flight and run writes through a single promise queue; on 409, re-fetch the object and retry the same change once before surfacing an error; and capture a view epoch when a write is queued so a result that returns after the user switched view is discarded instead of applied to the new view. Test the 409-retry in the API client with a mocked fetch.