This bug made it into the released versions of my Next.js 15 templates (two booking sites, a barbershop and a dental clinic, and two small online stores). All the tests were green. The booking flow had a row lock, an idempotency key and a race test. And it could still book the same customer twice.
Here's the flow it broke:
The customer submits the form.
The appointment is committed to Postgres.
The route sends a confirmation email with Nodemailer.
The route returns the link to the appointment page.
Step 3 is the problem. If the SMTP server is down, slow, or rejects the login, sendMail throws. The appointment is already saved, but the route returns a 500 and the customer sees "Something went wrong."
What does a normal person do after "Something went wrong"? Pressing the button again would actually have been safe, because the form reuses its idempotency key. But a lot of people reload and try again. The reloaded form has a new idempotency key, so the server sees a brand new request.…