Skip to content

adding rate limiting middleware#104

Merged
charithaT07 merged 2 commits intomainfrom
W-20908996-Rate-Limiting-Middleware
Feb 3, 2026
Merged

adding rate limiting middleware#104
charithaT07 merged 2 commits intomainfrom
W-20908996-Rate-Limiting-Middleware

Conversation

@charithaT07
Copy link
Copy Markdown
Collaborator

@charithaT07 charithaT07 commented Feb 2, 2026

Summary

Brief description of what this PR does.

This PR improves the SDK’s createRateLimitMiddleware to make rate-limit retries more reliable.

Retries now work even when openapi-fetch does not provide ctx.fetch, by falling back to config.fetch or the global fetch. The retry logic also adds safer backoff behavior, respects abort signals, and handles request cloning more carefully. Tests were updated to cover these changes.

Testing

How was this tested?


  • Tests pass (pnpm test)
  • Code is formatted (pnpm run format)

@charithaT07 charithaT07 marked this pull request as ready for review February 2, 2026 13:53
@charithaT07 charithaT07 requested a review from clavery as a code owner February 2, 2026 13:53
if (delayMs === undefined) {
delayMs = computeBackoffDelayMs(startingAttempt, baseDelayMs, maxDelayMs);
} else {
delayMs = Math.min(delayMs, maxDelayMs);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Math.min here seems to imply we might not always respect Retry-After headers from MRT. I think it's important we do.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated to always respect Retry-After and apply maxDelayMs only when needed

@charithaT07 charithaT07 requested a review from clavery February 2, 2026 17:53
Copy link
Copy Markdown
Collaborator

@clavery clavery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Will try to force this to happen in my testing

@charithaT07 charithaT07 merged commit 05fd75d into main Feb 3, 2026
3 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.

2 participants