Description
Observed behavior
Background: We use an experimental React SDK package @openfeature/react-sdk
, as well as LaunchDarkly OpenFeature client provider from @openfeature/launchdarkly-client-provider
. At the app's root level, we initialize context with
await OpenFeature.setProviderAndWait(provider);
before rendering any feature-flagged content.
When calling
const client = useOpenFeatureClient();
client?.providerStatus
yields NOT_READY
after it already transitioned to READY
, this happens roughly once in about 10 times.
We are using the following settings for the feature flag.
const enableSomeFeatureFlag = useBooleanFlagValue(
flagKey,
false,
{
suspendUntilReady: true,
updateOnConfigurationChanged: true,
updateOnContextChanged: true,
}
);
The component that contains the provider status call is wrapped in a Suspense, checking whether client?.providerStatus === 'READY'
before continuing with feature flag checks.
If NOT_READY
-> READY
transition occurs, it triggers a re-render for the component and the flags are properly evaluated.
If NOT_READY
-> READY
-> NOT_READY
transition occurs, it does not trigger a subsequent re-render.
This cannot be reproduced easily through DevTools, because time delay caused by debugging prevents the race condition.
Expected Behavior
When the component has loaded, the provider should not go from READY
to NOT_READY
state, but rather newly introduced RECONCILING
or similar if the feature flag context needs to be re-evaluated for some reason.
Alternatively, ensure that going back to NOT_READY
state (if allowed) should always re-evaluate a context, triggering a re-render.
At the moment, we don't have an easy way to force the reconciliation to ensure the feature flags will not fall back to their default values.
Steps to reproduce
Previous packages:
"@openfeature/launchdarkly-client-provider": "latest",
"@openfeature/react-sdk": "^0.1.0-experimental",
"@openfeature/web-sdk": "^0.4.10",
Updated packages (error manifested after this update):
"@openfeature/core": "^1.0.0",
"@openfeature/launchdarkly-client-provider": "^0.3.0",
"@openfeature/react-sdk": "^0.2.3-experimental",
"@openfeature/web-sdk": "^1.0.1",