Skip to content

chore: add retry configuration options for http requests#198

Draft
duyhungtnn wants to merge 2 commits into
masterfrom
chore/retry-on-499
Draft

chore: add retry configuration options for http requests#198
duyhungtnn wants to merge 2 commits into
masterfrom
chore/retry-on-499

Conversation

@duyhungtnn
Copy link
Copy Markdown
Collaborator

@duyhungtnn duyhungtnn commented Apr 14, 2026

#199
This pull request introduces a robust and configurable retry mechanism for HTTP requests, including support for the Retry-After header, exponential backoff with jitter, and comprehensive configuration validation and defaults. It also adds extensive unit tests to ensure correct parsing and propagation of retry-related logic throughout the codebase.

Retry logic and error handling improvements:

  • Added a new promiseRetriable utility in src/utils/promiseRetriable.ts that provides generic, configurable retry logic with exponential backoff and jitter, as well as logic to respect the Retry-After header and classify retryable errors and status codes.
  • Enhanced the InvalidStatusError class in src/objects/errors.ts to include an optional retryAfterMs property, and added a parseRetryAfter function to parse both delta-seconds and HTTP-date formats from the Retry-After header.
  • Updated the HTTP client in src/api/client.ts to parse the Retry-After header from error responses and propagate it via InvalidStatusError, ensuring that retry logic can use this information. [1] [2]

Configuration and validation:

  • Introduced new retry-related configuration options (maxRetries, retryInitialInterval, retryMaxInterval) to the BKTConfig interface in src/config.ts, with sensible defaults and validation logic to handle negative or inconsistent values. [1] [2] [3] [4] [5]
  • Updated test configuration helpers and conversion logic to reflect and test these new retry options. [1] [2] [3]

@duyhungtnn duyhungtnn changed the title feat: add promiseRetriable utility and tests chore: add retry configuration options for http requests Apr 15, 2026
@duyhungtnn duyhungtnn force-pushed the chore/retry-on-499 branch from 53c21ca to 155bd57 Compare May 31, 2026 15:08
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.

1 participant