Feat/request timeout retry - #1072
Open
Nithin0620 wants to merge 2 commits into
Open
Conversation
Member
|
Thank you so much for this; this looks really interesting! Three things that come to mind:
|
Author
|
Thanks for the feedback! Makes total sense.
|
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
Adds three optional request controls to the SDK, all opt-in and backward compatible
(no behavior change unless you set them):
timeoutMs— abort a request attempt after N ms (per attempt, so retries still get a fair shot)retries— retry retryable failures (HTTP 429, 5xx, network errors) with exponential backoff, honoring theRetry-Afterheadersignal— pass anyAbortSignalto cancel a requestSet them globally in the constructor or per call:
Why
Currently a request can hang indefinitely and rate limits / transient 5xx fail
immediately with no retry. These options bring the SDK in line with how the other
official Resend SDKs and major API clients behave.
Notes
explicit choice, so idempotency-sensitive flows are unaffected by default.
Tests
429 retry with Retry-After, 5xx retry, no retry on 4xx, per-request override.
Commits
dropping per-request options (get(url) → get(url, options)); this makes
emails.list({ retries: 2 }) actually work. The bulk of the file count is this
one-line mechanical change.
Summary by cubic
Adds opt-in request controls to the SDK—
timeoutMs,retries, andsignal—and fixes list methods to forward per-request options. Previously requests could hang and never retried 429/5xx/network errors; now, when configured, requests abort on timeout and retry resiliently while honoringRetry-After.AbortSignal, retries for 429/5xx/network errors with exponential backoff and jitter;Retry-Afterrespected; timeouts and aborts are not retried; defaultretriesis 0.RequestOptionsinterface added and included inGetOptions,PostOptions,PutOptions,PatchOptions, andPaginationOptions. Options can be set in the constructor or per call; README documents usage.optionstothis.resend.get(...)so per-request controls apply to list endpoints.src/resend.ts(fetchRequest,performRequest,buildErrorResponse,parseRetryAfter); review timeout handling and cleanup of abort listeners.Retry-After, 5xx retry, no retry on 4xx, and per-request override.timeoutMs,retries, orsignalglobally or per request.Written for commit 27edc21. Summary will update on new commits.