-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Fix campaign broadcast email chunking #3202
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 GitHub.
|
|
Warning Rate limit exceeded@devkiran has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 18 minutes and 17 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
WalkthroughThe broadcast campaign route now splits partnerUsers into EMAIL_BATCH_SIZE chunks, sends each chunk with a unique per-chunk idempotency key, creates NotificationEmail records after each chunk's successful response, and preserves per-chunk error handling and batching delays. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant CronRoute as API Route
participant ChunkSender as sendBatchEmail / Email Provider
participant DB as Database (NotificationEmail)
participant Enqueue as Batch Enqueue / Scheduler
CronRoute->>CronRoute: split partnerUsers into chunks
loop for each chunk i
CronRoute->>ChunkSender: sendChunk(payload, idempotencyKey_i)
alt success
ChunkSender-->>CronRoute: success + data
CronRoute->>DB: create NotificationEmail records for chunk i
CronRoute->>Enqueue: schedule next overall batch (if applicable)
else failure
ChunkSender-->>CronRoute: error
CronRoute->>CronRoute: log error, continue or halt per logic
end
CronRoute->>CronRoute: optional delay between chunks
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
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. Comment |
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
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/web/app/(ee)/api/cron/campaigns/broadcast/route.ts(2 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-11-17T05:19:11.972Z
Learnt from: devkiran
Repo: dubinc/dub PR: 3113
File: apps/web/app/(ee)/api/cron/payouts/charge-succeeded/send-paypal-payouts.ts:65-75
Timestamp: 2025-11-17T05:19:11.972Z
Learning: In the Dub codebase, `sendBatchEmail` (implemented in packages/email/src/send-via-resend.ts) handles filtering of emails with invalid `to` addresses internally. Call sites can safely use non-null assertions on email addresses because the email sending layer will filter out any entries with null/undefined `to` values before sending. This centralized validation pattern is intentional and removes the need for filtering at individual call sites.
Applied to files:
apps/web/app/(ee)/api/cron/campaigns/broadcast/route.ts
📚 Learning: 2025-11-12T22:23:10.414Z
Learnt from: TWilson023
Repo: dubinc/dub PR: 3098
File: apps/web/lib/actions/partners/message-program.ts:49-58
Timestamp: 2025-11-12T22:23:10.414Z
Learning: In apps/web/lib/actions/partners/message-program.ts, when checking if a partner can continue messaging after messaging is disabled, the code intentionally requires `senderPartnerId: null` (program-initiated messages) to prevent partners from continuing to send junk messages. Only conversations started by the program should continue after messaging is disabled, as a spam prevention mechanism.
Applied to files:
apps/web/app/(ee)/api/cron/campaigns/broadcast/route.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
🔇 Additional comments (1)
apps/web/app/(ee)/api/cron/campaigns/broadcast/route.ts (1)
12-12: Import additions align with downstream usage
APP_DOMAIN_WITH_NGROK,chunk, andlogare all used below (QStash URL, partner user chunking, and logging), so this import change is consistent and safe.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.