r/databasedevelopment • u/Ok-Device-7309 • 14h ago
Every dashboard is green: 0% errors, p99 under 800 ms. But 13,000 paid orders a day never ship. Can you find the 3 bugs?
A shop takes payments with Stripe Checkout. 3,000 requests a second at the peak, 90 of them people paying.
Here's how an order goes through:
- The buyer pays on Stripe's checkout page.
- Stripe sends the buyer's browser back to
/thank-you. That request marks the order paid and books the courier. - Stripe also calls the shop's webhook to say the payment went through. The handler saves the payment, emails the receipt and updates stock, then answers
200 OK.
The dashboards look perfect: 0% of requests fail, p99 is 788 ms and no server is overloaded.
Support says otherwise:
- "I paid and my order never came." About 13,000 a day.
- "I got two receipts and stock went down twice." About 2,600 a day.
- Stripe's dashboard shows about 51,800 failed webhook deliveries a day.
Try to find all three bugs before you open the spoilers.
Bug 1: >!The order is sent from the thank-you page. Buyers who close the tab or lose signal after paying never come back, so their orders never ship. The webhook arrives either way, so the webhook should send the order. The thank-you page is just a page.!<
Bug 2: >!Webhooks arrive at least once, not exactly once. The same event can come twice, so the handler runs twice. Save each event's ID and skip any ID you've already handled.!<
Bug 3: >!The handler does the slow work (saving, emailing, stock) before it answers. Slow answers time out, Stripe marks them failed and sends them again, which makes bug 2 worse. Save the event, answer right away, and let a worker do the rest from a queue.!<
What Stripe's docs actually say:
- The same event can reach your endpoint more than once, and events aren't guaranteed to arrive in order.
- Stripe retries a failed webhook for up to three days in live mode, and asks you to answer with a success code before any slow logic.
- Stripe's fulfilment guide sends orders from the
checkout.session.completedwebhook, not the redirect.
Scale matters here because rare cases add up. Stripe reported more than 578 million payments from Black Friday to Cyber Monday 2025, peaking above 152,000 a minute. If 1 in 1,000 events repeats, that's a lot of double receipts.
The same three fixes apply to PayPal, Razorpay, Shopify, GitHub and any provider that calls you back.
I turned this into a level in Bugpit, a free browser game where you build a backend from blocks, send traffic at it and watch what breaks. The numbers above come from that simulation. How often buyers close the tab and how often events repeat are my estimates. The Stripe behaviour is from their docs. This level is in Pro, but 43 levels are free with an account, and the first few open without one: https://bugpit.vercel.app
Which bug have you actually hit in production? Bug 1 seems to catch most teams.