Skip to content
3 changes: 3 additions & 0 deletions packages/remote-feature-flag-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Add exponential backoff strategy in `ClientConfigApiService` to use proper Cockatiel `ExponentialBackoff` implementation ([#6922](https://github.com/MetaMask/core/pull/6922))
- Replace custom `ExponentialMinuteBackoff` class with `createMinuteBasedExponentialBackoff()` function that configures Cockatiel's `ExponentialBackoff` with minute-based intervals
- Ensures retry mechanism correctly implements the specified timing progression: 1st retry after 1 minute, 2nd retry after 2 minutes, 3rd retry after 4 minutes
- Bump `@metamask/base-controller` from `^8.4.1` to `^8.4.2` ([#6917](https://github.com/MetaMask/core/pull/6917))

## [1.9.0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
DEFAULT_CIRCUIT_BREAK_DURATION,
DEFAULT_MAX_CONSECUTIVE_FAILURES,
DEFAULT_MAX_RETRIES,
ExponentialBackoff,
} from '@metamask/controller-utils';
import type { ServicePolicy } from '@metamask/controller-utils';

Expand All @@ -17,6 +18,24 @@ import type {
ApiDataResponse,
} from '../remote-feature-flag-controller-types';

/**
* Custom backoff factory that implements exponential progression in minutes.
* 1st retry: 1 minute, 2nd retry: 2 minutes, 3rd retry: 4 minutes, etc.
* Uses Cockatiel's ExponentialBackoff with minute-based intervals.
*
* @returns A Cockatiel ExponentialBackoff instance configured for minute-based intervals.
*/
function createMinuteBasedExponentialBackoff() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding this as an argument to the constructor apply the existing default values. This show allow backwards compatibility and customization for the mobile client.

return new ExponentialBackoff({
// Start with 1 minute base delay (60,000 ms)
initialDelay: 60 * 1000,
// Use a multiplier of 2 for exponential progression (1min, 2min, 4min, 8min...)
exponent: 2,
// Maximum delay to prevent extremely long waits
maxDelay: 15 * 60 * 1000, // 15 minutes max
});
}

/**
* This service is responsible for fetching feature flags from the ClientConfig API.
*/
Expand Down Expand Up @@ -138,6 +157,7 @@ export class ClientConfigApiService implements AbstractClientConfigApiService {
maxRetries: retries,
maxConsecutiveFailures: maximumConsecutiveFailures,
circuitBreakDuration,
backoff: createMinuteBasedExponentialBackoff(),
});
if (onBreak) {
this.#policy.onBreak(onBreak);
Expand Down
Loading