Architecture Lab · LAB-09UNSOLVED
The Order That Was Placed Twice
One customer. One click. Two charges. The button has a disabled state and the developer added it specifically to prevent this.
- Status
- UNSOLVED
- Level
- SYSTEMS
- Threads
- 05
- Suspects
- 04
The scene
Support reports duplicate orders at a rate of about 1 in 900. The handler disables the button on submit. Logs show two POST requests, 40ms apart, from the same session, with identical bodies.
example.jsxjsx
function Checkout() { const [busy, setBusy] = useState(false); async function submit() { if (busy) return; setBusy(true); await placeOrder(cart); setBusy(false); } return <button onClick={submit} disabled={busy}>Place order</button>;}01Evidence board0 / 3 material findings
02Name a suspect
Resolution sealed until a suspect is named
References
- 01IETF draftIdempotency-Key header
- 02React docsuseRef