-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Use Resend batch endpoint #2514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe email notification logic for partner ACH payouts was refactored to use the Changes
Sequence Diagram(s)sequenceDiagram
participant ConfirmPayouts
participant ResendService
participant Logger
ConfirmPayouts->>ConfirmPayouts: Check if resend is configured
alt Not configured
ConfirmPayouts->>Logger: Log error and return
else Configured
ConfirmPayouts->>ConfirmPayouts: Filter payouts with partner emails
ConfirmPayouts->>ConfirmPayouts: Chunk emails into batches of 100
loop For each batch
ConfirmPayouts->>ResendService: Send batch via resend.batch.send
end
end
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (1)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR replaces individual email sends with Resend’s batch endpoint for partner payout confirmations, adds chunking to respect batch limits, and improves logging when Resend is misconfigured.
- Swapped out
limiter.schedule+sendEmailforresend.batch.sendcalls. - Introduced chunking of up to 100 emails per batch and a guard/log if
resendis not configured. - Updated imports to include
chunk,log, and Resend-specific constants.
Comments suppressed due to low confidence (1)
apps/web/app/(ee)/api/cron/payouts/confirm/confirm-payouts.ts:170
- New chunking and batch logic should be covered by unit or integration tests to ensure correct splitting and handling of edge cases (e.g., fewer than 100 emails).
const payoutChunks = chunk(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
apps/web/app/(ee)/api/cron/payouts/confirm/confirm-payouts.ts (2)
160-168: Duplicate logging & missing alerting channel
await log(...)already records the error; the extraconsole.logis redundant and can leak sensitive operational details in production logs.- await log({ - message: "Resend is not configured, skipping email sending.", - type: "errors", - }); - console.log("Resend is not configured, skipping email sending."); + await log({ + message: "Resend is not configured, skipping email sending.", + type: "errors", + });If this scenario really “should never happen”, consider escalating (e.g. throw or page) instead of silently continuing.
170-192: Sequential batches may be slow; consider limited parallelismSending 10 000 emails will require 100 sequential
awaits. Resend’s rate limits are generous (300 req/s) so you could send, say, 3-5 chunks in parallel without risking throttling:for (const chunk of payoutChunks) { tasks.push(resend.batch.send(/* … */)); if (tasks.length === 5) { await Promise.all(tasks); tasks.length = 0; } } await Promise.all(tasks);Not critical for small volumes but worth considering for larger partner bases.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/web/app/(ee)/api/cron/payouts/confirm/confirm-payouts.ts(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
apps/web/app/(ee)/api/cron/payouts/confirm/confirm-payouts.ts (3)
packages/email/src/resend/client.ts (1)
resend(3-5)packages/email/src/resend/constants.ts (1)
VARIANT_TO_FROM_MAP(6-10)packages/email/src/templates/partner-payout-confirmed.tsx (1)
PartnerPayoutConfirmed(18-122)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build
🔇 Additional comments (1)
apps/web/app/(ee)/api/cron/payouts/confirm/confirm-payouts.ts (1)
8-13: 👍 Imports look good but consider tree-shaking awarenessThe new imports (
resend,VARIANT_TO_FROM_MAP,chunk,log) are concise and keep concerns separated.
Small nit: when this file is bundled for the edge runtime, every additional import can increase cold-start time. Make sure@dub/utilsand@dub/emailare already marked as ‑edge-safe / tree-shakeable to avoid pulling in heavyweight code paths accidentally.
|
🤖 Bug0 QA Agent Here are the results of the automated tests for PR #2514:
To re-run the tests, please comment |
|
🤖 Bug0 QA Agent Here are the results of the automated tests for PR #2514:
To re-run the tests, please comment |
|
@CodeRabbit final review |
|
Tip For best results, initiate chat on the files or code changes. @steven-tey Sure thing—running a quick pass over the updated diff one more time to make sure nothing slipped though. I’ll follow-up with any last-minute notes (or a ✅ if everything’s ship-shape) in just a moment. |
|
@CodeRabbit final review pls |
|
Tip For best results, initiate chat on the files or code changes. @steven-tey ✅ All good from my side—no additional issues surfaced on this final pass. The switch to Only tiny “nice-to-have” you may consider later (doesn’t block merge): Otherwise, LGTM—ship it! 🚢✨ |
|
🤖 Bug0 QA Agent Here are the results of the automated tests for PR #2514:
To re-run the tests, please comment |
Summary by CodeRabbit