Skip to content

Add Retry Logic to Feature Flag Controller #20957

@sethkfman

Description

@sethkfman

What is this about?

As a user I want to consistently see features enabled by the remote flag system.

Issue: Currently the feature flag controller doesn't support a retry on the failure of an API call.

Solution: Add a 3x retry option to the constructor base on these guidelines.

/**
     * Constructs a new ClientConfigApiService object.
     *
     * @deprecated This signature is deprecated; please use the `onBreak` and
     * `onDegraded` methods instead.
     * @param args - The arguments.
     * @param args.fetch - A function that can be used to make an HTTP request.
     * If your JavaScript environment supports `fetch` natively, you'll probably
     * want to pass that; otherwise you can pass an equivalent (such as `fetch`
     * via `node-fetch`).
     * @param args.retries - Number of retry attempts for each fetch request.
     * @param args.maximumConsecutiveFailures - The maximum number of consecutive
     * failures allowed before breaking the circuit and pausing further fetch
     * attempts.
     * @param args.circuitBreakDuration - The amount of time to wait when the
     * circuit breaks from too many consecutive failures.
     * @param args.onBreak - Callback for when the circuit breaks, useful
     * for capturing metrics about network failures.
     * @param args.onDegraded - Callback for when the API responds successfully
     * but takes too long to respond (5 seconds or more).
     * @param args.config - The configuration object, includes client,
     * distribution, and environment.
     * @param args.config.client - The client type (e.g., 'extension', 'mobile').
     * @param args.config.distribution - The distribution type (e.g., 'main',
     * 'flask').
     * @param args.config.environment - The environment type (e.g., 'prod', 'rc',
     * 'dev').
     */
    constructor(args: {
        fetch: typeof fetch;
        retries?: number;
        maximumConsecutiveFailures?: number;
        circuitBreakDuration?: number;
        onBreak?: () => void;
        onDegraded?: () => void;
        config: {
            client: ClientType;
            distribution: DistributionType;
            environment: EnvironmentType;
        };
    });

Scenario

No response

Design

No response

Technical Details

No response

Threat Modeling Framework

No response

Acceptance Criteria

No response

Stakeholder review needed before the work gets merged

  • Engineering (needed in most cases)
  • Design
  • Product
  • QA (automation tests are required to pass before merging PRs but not all changes are covered by automation tests - please review if QA is needed beyond automation tests)
  • Security
  • Legal
  • Marketing
  • Management (please specify)
  • Other (please specify)

References

No response

Metadata

Metadata

Labels

release-7.58.0Issue or pull request that will be included in release 7.58.0team-mobile-platformMobile Platform team

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions