Conversation
Allow users to configure a custom rate limit (in milliseconds between API calls) via the new `rateLimitMs` option. This is useful for accounts that have a higher rate limit approved by Resend. - Default remains 600ms for most users (uses existing rate limiter) - Custom rates use timestamp-based rate limiting stored in lastOptions table - Added JSDoc documentation explaining when to change this value Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughA new runtime option Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Resend
participant Component as "Component.makeBatch"
participant Store as "lastOptions Store"
participant API as "External API"
Client->>Resend: sendEmail(options with rateLimitMs)
Resend->>Component: makeBatch(options, runtimeConfig)
Component->>Store: read lastApiCallTime (if custom rate)
alt default rate (fixed-window)
Component->>Component: use fixed-window rate limiter -> may delay
else custom rate
Component->>Component: compute elapsed, jitter, delay
Component->>Store: update lastApiCallTime (reserve slot)
end
Component->>API: perform API call(s) after delay
API-->>Component: response
Component-->>Resend: result
Resend-->>Client: deliver response
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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. Comment |
commit: |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/component/lib.ts`:
- Around line 445-447: Guard against undefined rateLimitMs by defaulting
options.rateLimitMs (or lastOptions.options.rateLimitMs) to a safe number before
calling getDelay so it never receives undefined and returns NaN; also when
updating lastApiCallTime after computing delay, include the reserved jitter (the
same jitter used by getDelay) so the stored lastApiCallTime = now +
reservedDelay (delay including jitter) to avoid under‑reservation—update
references to getDelay(ctx, options.rateLimitMs), lastOptions.options, and
lastApiCallTime accordingly to apply the default and add the jitter when saving
the timestamp.
- Default rateLimitMs to 600ms if undefined to prevent NaN - Include jitter when storing lastApiCallTime to avoid under-reservation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary
rateLimitMsoptionTest plan
🤖 Generated with Claude Code
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.