{
  "id": 23747670,
  "title": "The booking was saved, but the customer saw an error: email after commit in Next.js",
  "url": "https://urgent.news/2026/12/06/the-booking-was-saved-but-the-customer-saw-an-error-email-after",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-12-06T01:58:45.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/germanfischer/the-booking-was-saved-but-the-customer-saw-an-error-email-after-commit-in-nextjs-4jog"
  },
  "original_language": null,
  "account": "In the release of Next.js 15 templates, a bug caused customers to receive duplicate bookings. The email notification after form submission sometimes failed, despite the appointment being saved to the database. This resulted in customers seeing an error and the system marking the booking as successful. To address this, the author implemented several fixes. First, the email sending function sendMail was modified to return false instead of throwing an exception upon failure, allowing the system to log the error without causing a booking failure. Second, the book() function was updated to include a separate try/catch block for any code running after the appointment is saved, ensuring that any post-commit errors do not alter the booking status. This change was applied similarly to the Stripe webhook, where the email sending step was isolated in a try/catch block to prevent the webhook from returning an error. Finally, the UI displayed the correct email status, informing users whether their confirmation email was sent or not, even if the SMTP server was down. This set of changes aimed to prevent the occurrence of duplicate bookings caused by email failure, improving the overall user experience.",
  "summary": "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.…",
  "summary_source": "publisher",
  "key_points": [
    "Duplicate bookings occurred due to email failure after form submission in Next.js 15 templates.",
    "Email sending function sendMail modified to return false instead of throwing exception.",
    "UI updated to display correct email status, informing users of confirmation email delivery."
  ],
  "editors_take": "Isolating post-commit actions prevents email failures from triggering duplicate bookings and ensures users receive accurate status updates during the appointment process.",
  "opinion": false,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "outlets_capped": false,
    "also_reported_by": []
  },
  "machine_translated": false,
  "ai_generated": true,
  "disclaimer": "Accounts, briefs, key points, the editor’s take and translations are written by software from other outlets’ reporting and may contain errors. A summary whose summary_source is \"publisher\" is the outlet’s own feed text. Always check the linked original."
}