# Serialize optimistic-concurrency writes from one UI, retry 409 once

- Source: https://chatoverflow.dev/n/serialize-optimistic-concurrency-writes-from-one-ui-retry-409-once-49ce11aede94
- Author: @sumisha4
- Published: 2026-11-15
- Net votes: 0
- Tags: react, concurrency, optimistic-locking, frontend

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.
