feat: support auto retry for http requests - #198
Merged
Conversation
duyhungtnn
force-pushed
the
chore/retry-on-499
branch
from
April 16, 2026 15:33
aa2a4ca to
5f3639e
Compare
duyhungtnn
force-pushed
the
chore/retry-on-499
branch
from
May 31, 2026 15:08
53c21ca to
155bd57
Compare
There was a problem hiding this comment.
Pull request overview
Adds configurable HTTP retry behavior to the Bucketeer Node server SDK, wiring retry policy from configuration into the API client and introducing per-call abort/deadlines to keep polling and request lifecycles bounded.
Changes:
- Introduces a generic
promiseRetriableutility (exponential backoff + jitter +Retry-Aftersupport) and threads retry metadata viaInvalidStatusError.retryAfterMs. - Adds retry-related config fields (
maxRetries,retryInitialInterval,retryMaxInterval,retryMultiplier) with defaults/validation and propagates them intoAPIClient. - Adds abort-signal based cancellation for polling and key calls, plus extensive unit tests for retry/backoff,
Retry-Afterparsing, and polling cancellation.
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tsconfig.test.json | Ensures test compilation includes src/**/*. |
| src/utils/promiseRetriable.ts | New retry helper with backoff/jitter and retryability classification. |
| src/utils/pollController.ts | New helper to create/replace polling-bound abort signals. |
| src/objects/errors.ts | Adds parseRetryAfter and InvalidStatusError.retryAfterMs. |
| src/index.ts | Builds retry policy from resolved config and passes it to APIClient. |
| src/config.ts | Adds retry config fields, defaults, and validation logic. |
| src/client.ts | Adds per-call timeouts via AbortSignal.timeout(...) for key API calls. |
| src/cache/processor/segmentUsersCacheProcessor.ts | Uses PollController signal to bound/cancel polling requests. |
| src/cache/processor/featureFlagCacheProcessor.ts | Uses PollController signal to bound/cancel polling requests. |
| src/api/client.ts | Adds retry wrapper and Retry-After parsing/propagation in HTTP errors. |
| src/tests/promise_retriable.ts | Unit tests for retry behavior, backoff, status/network retryability, and abort support. |
| src/tests/poll_controller.ts | Unit tests for PollController behavior. |
| src/tests/parse_retry_after.ts | Unit tests for Retry-After parsing and retryAfterMs property. |
| src/tests/mocks/api.ts | Updates mock API client signatures to accept optional AbortSignal. |
| src/tests/define_bkt_config.ts | Adds tests for retry config defaults/validation. |
| src/tests/convert_config_to_bkt_config.ts | Verifies deprecated config conversion includes retry defaults. |
| src/tests/client.ts | Adjusts test to avoid retryable 5xx behavior impacting runtime. |
| src/tests/client_graceful_shutdown.ts | Updates test config to include retry fields. |
| src/tests/client_graceful_shutdown_batching.ts | Updates test config to include retry fields. |
| src/tests/client_get_evaluation_metrics_events.ts | Updates test config to include retry fields. |
| src/tests/cache/processor/segementUsersCache/init.ts | Updates expectations for new AbortSignal parameter. |
| src/tests/cache/processor/featureCache/polling.ts | Updates expectations for new AbortSignal parameter. |
| src/tests/cache/processor/featureCache/init.ts | Updates expectations for new AbortSignal parameter. |
| src/tests/api_retry_after.ts | Adds integration-style tests asserting Retry-After propagation. |
| ava-test.config.mjs | Sets a global AVA timeout of 30s. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
duyhungtnn
commented
Jun 11, 2026
duyhungtnn
commented
Jun 11, 2026
duyhungtnn
commented
Jun 11, 2026
duyhungtnn
commented
Jun 11, 2026
duyhungtnn
marked this pull request as ready for review
June 11, 2026 16:07
duyhungtnn
marked this pull request as draft
June 12, 2026 01:37
Update DEFAULT_FLUSH_INTERVAL_MILLIS from 10_000 to 30_000 and revise comments to clarify that the minimum flush interval remains 10s while the default is 30s. This ensures the default flush cadence is less frequent than the enforced minimum and makes intent explicit in the code comments.
Config validation now rejects zero (previously only negative) and resets to the 1 s default with a warning, matching Go SDK behavior. calculateBackoff also enforces the same floor as defense-in-depth, so bypassing config cannot produce zero-delay retries.
…deduplicate retry constants
duyhungtnn
force-pushed
the
chore/retry-on-499
branch
from
June 17, 2026 04:55
6ff8e2d to
00759f1
Compare
Merged
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.
#199
This pull request introduces a robust and configurable retry mechanism for HTTP requests, including support for the
Retry-Afterheader, 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:
promiseRetriableutility insrc/utils/promiseRetriable.tsthat provides generic, configurable retry logic with exponential backoff and jitter, as well as logic to respect theRetry-Afterheader and classify retryable errors and status codes.InvalidStatusErrorclass insrc/objects/errors.tsto include an optionalretryAfterMsproperty, and added aparseRetryAfterfunction to parse both delta-seconds and HTTP-date formats from theRetry-Afterheader.src/api/client.tsto parse theRetry-Afterheader from error responses and propagate it viaInvalidStatusError, ensuring that retry logic can use this information. [1] [2]Configuration:
maxRetries,retryInitialInterval,retryMaxInterval) to theBKTConfiginterface insrc/config.ts, with sensible defaults and validation logic to handle negative or inconsistent values. [1] [2] [3] [4] [5]Validation: