Menu

The booking was saved, but the customer saw an error: email after commit in Next.js
📰

The booking was saved, but the customer saw an error: email after commit in Next.js

DEV Community: node·German Fischer·about 6 hours ago
#Ld6k2RG7
#devtonodejs#devto#dev#email#booking
Long article (1776 words) — no AI summary yet.
Reading 0:00
15s threshold

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.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.