Skip to content

Fix FeatureFlagClient to handle race conditions calls

Created by: erzhtor

Part 2 of https://github.com/sourcegraph/sourcegraph/issues/35543. Follow-up https://github.com/sourcegraph/sourcegraph/pull/35531.

Description

There are cases when initial calls to the FeatureFlagClient instance happen before the fetch request (which is called in the constructor) completes. This PR:

  • Fixes it to always return fetched results
  • Also, updates useFeatureFlag to use useObservableWithStatus
  • Updates withFeatureFlag to allow rendering two components (when flag=true and when flag=false) and adds unit tests to

Test plan

  • Unit tests added

App preview:

Check out the client app preview documentation to learn more.

Merge request reports

Loading