feat: add HTTP 429 rate limit retry support#83
Merged
mikeh-lago merged 10 commits intomainfrom Apr 13, 2026
Merged
Conversation
- Add LagoRateLimitError class for 429 responses - Parse x-ratelimit-* headers from responses - Implement automatic retry on 429 with configurable max retries - Support header-based reset timing and exponential backoff - Create fetch wrapper to intercept and handle rate limiting - Add LagoClientConfig with rateLimitRetry options - Include comprehensive tests for all rate limiting features - Add RATE_LIMITING.md documentation - Add rate_limiting_example.ts with usage patterns - Maintain backward compatibility with existing API - Do not modify generated OpenAPI code
mock_fetch library's URLPattern is incompatible with current Deno. Replace with a lightweight createMockFetch helper. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ed docs - Fix getWaitTime to actually fall back to exponential backoff (1s, 2s, 4s...) when x-ratelimit-reset header is missing. Previously always used error.retryAfter which defaulted to 60s, meaning every retry without a header waited a full minute. - Change missing-header default from 60 to -1 so the backoff path is triggered correctly. - Remove RateLimitRetryHandler class (rate_limit_retry.ts) — both branches of handleResponse() threw unconditionally, making the retryOnRateLimit flag a no-op. The class was never used by createRateLimitFetch. Remove its export from mod.ts. - Remove RATE_LIMITING.md (394 lines) and examples/rate_limiting_example.ts (305 lines of commented-out code). - Add test verifying exponential backoff triggers ~1s wait (not 60s) when reset header is absent. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Local Deno generated lockfile v5 which is unsupported by CI's Deno 1.46.3. Removing so CI can regenerate. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Prevents excessively long waits when the server returns a large x-ratelimit-reset value. Applies to both header-based and exponential backoff delays. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
LagoRateLimitErrorclass andparseRateLimitHeadersutilitycreateRateLimitFetchwrapper with configurable retry and backoffClientviarateLimitRetryconfig optionTest plan
🤖 Generated with Claude Code