Skip to content

fix: reuse request keys for identical queued email digests - #827

Merged
NewWorldVenture merged 5 commits into
mainfrom
codex/queued-email-digest-idempotency-20261002
Oct 3, 2026
Merged

NewWorldVenture merged 5 commits into
mainfrom
codex/queued-email-digest-idempotency-20261002

Conversation

@NewWorldVenture

Copy link
Copy Markdown
Owner

Overlapping notification-email workers can accept and report the same digest twice before sent_at is acknowledged. Reuse a deterministic recipient-and-row-set key for identical digests, forward it through the email helper's optional Resend SDK options, and give equal-time rows a stable ID order. Existing callers without a key keep their one-argument SDK call.

This draft targets main and is based on PR #787 (bec49a6). Its own commit changes exactly lib/server/notification-emails.ts, lib/email.ts and tests/queued-email-idempotency.test.ts; it inherits #787's membership/preference fix and tests. Merge #787 first or include both in the reviewed composition.

Validation: author and independent root final17 pass, versus the identical suite on the original sources failing8 cases with9 controls. Original seven test declarations are preserved. All56 related tests in5 files, full nonincremental TypeScript and three-file lint pass. Tests use actual Supabase SDK synthetic transport, the real email helper with an inert documented provider model, and an intercepted installed Resend6.14.0 header boundary. No live sending or rendering was exercised.

Bounded guarantee: identical payload/row-set retries within the provider's24-hour key window. In-flight409 and changed-payload409 remain failures with pending rows; accepted replay counts as an accepted request, not a new physical delivery. Changed batches, partial acknowledgments, expiry, live provider behavior and atomic authorization remain open. No mutex, premark-sent, migrations, provider configuration or audit closure.

Ownership and evidence: #771 (comment) and #787 (comment). Provider contract: https://resend.com/docs/dashboard/emails/idempotency-keys.

@vercel

vercel Bot commented Oct 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
bubaly Ignored Ignored Oct 2, 2026 4:56pm UTC

Request Review

@NewWorldVenture
NewWorldVenture merged commit 3d4a29a into main Oct 3, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant