Dubbele factuur-mail door race-conditie in finalizeAcceptedQuote #96
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
jesse-a/OpenCRM#96
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Severity: MEDIUM (data-integriteit)
finalizeAcceptedQuote()insrc/lib/quote-finalize.tshadif (!invoice.emailedAt) { send; update }— non-atomair. Tussen check en update zat een 5-10s window (SMTP-send + Mollie-API). Twee parallel-aanroepen konden allebei door de check heen → klant kreeg dezelfde factuur 2× per mail.Triggers in productie:
Fix:
prisma.invoice.updateMany({ where: { id, emailedAt: null }, data: { emailedAt: now } }). DB doet 1 UPDATE die maximaal 1 rij raakt. Zelfde patroon toegepast op payment-reminders-cron.Files: src/lib/quote-finalize.ts, src/app/api/cron/payment-reminders/route.ts
Opgelost in commit
ec4baeb.