feat: auto retry rate limit#53
Merged
Merged
Conversation
Bake rate-limit (429) and server-error (5xx) retry/back-off into the request layer so callers no longer need their own retry loops. - 429s are retried indefinitely, respecting the Retry-After header (falling back to retryAfterFallback seconds when absent). Applies to all methods, since a 429 is rejected before processing. - 5xx errors are retried up to maxServerErrorRetries times (default 5) for GET only, since writes may not be idempotent. The last Response is returned once retries are exhausted, keeping the existing return contract intact. - Every retry is re-scheduled through the limiter, with random jitter added to each wait. - Configurable (and disablable) via the new `retry` setting. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The library now retries rate-limited requests automatically, so the manual getPage-based retry in the example is no longer needed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds automatic retry behavior to Fast42 API requests, integrating rate-limit (429) and server-error (5xx) retries into the internal request scheduling so callers can keep using the existing Response contract.
Changes:
- Introduces
retryconfiguration (RetryConfig) with defaults and a master enable/disable switch. - Wraps internal request scheduling with
scheduleWithRetryto transparently retry 429s (indefinitely) and GET 5xx responses (bounded). - Adds Jest coverage for the retry behavior and documents configuration/behavior in the README.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/index.ts |
Adds retry config defaults and implements scheduleWithRetry used by GET and write requests. |
tests/index.test.ts |
Adds unit tests validating 429 and 5xx retry behavior and default retry settings. |
README.md |
Documents the new retry feature and configuration and removes now-unneeded manual 429 retry example logic. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
github-actions Bot
pushed a commit
that referenced
this pull request
Jun 24, 2026
# [3.0.0](v2.2.0...v3.0.0) (2026-06-24) ### Features * auto retry rate limit ([#53](#53)) ([fb335c6](fb335c6)) * use native fetch instead of node-fetch ([a878ea2](a878ea2)) ### BREAKING CHANGES * node-fetch has been removed. Consumers must run on Node.js 18 or newer, and the exported Response type is now the native (undici) Response rather than node-fetch's. The methods this library uses are identical, but code relying on node-fetch-specific Response behavior (e.g. body as a Node stream) may need adjusting.
|
🎉 This PR is included in version 3.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Added retry logic that automatically requeues requests when they return a 429 or 5xx error.
Retry-Afterheader (orretryAfterFallbackseconds when it is absent). Applies to every request, including writes — a 429 is rejected before processing, so it is always safe to retry.maxServerErrorRetriestimes (default 5), waitingserverErrorBackoffms between attempts. OnlyGETrequests are retried on 5xx, since writes (post/put/patch/delete) may not be idempotent. After the retries are exhausted the lastResponseis returned, so existing.ok/.statuschecks keep working.Added more config for this: