configcat / react-sdk

ConfigCat SDK for React. ConfigCat is a hosted feature flag service: https://configcat.com. Manage feature toggles across frontend, backend, mobile, desktop apps. Alternative to LaunchDarkly. Management app + feature flag SDKs.
MIT License
12 stars 7 forks source link

Error 1001 when using configcat provider in micro-frontend. #54

Open Amf1k opened 1 month ago

Amf1k commented 1 month ago

Describe the bug

We use Module Federation with webpack (version 5.88.1) and feature flags from ConfigCat (sdk version - 4.6.0) in our project. We have feature flags both in the host application and in the plug-in module, since the module can be connected to other host applications, so we have a separate config for the module. Therefore, we also initialize ConfigCatProvider in the module and pass the sdk key (different from the host one) to it. It turns out that we have a ConfigCatProvider nested in ConfigCatProvider. When initializing the module and calculating the flags, we get error 1001, which means that it is impossible to evaluate the flags from the host application in the module, since they are simply not in the config.

remote-entry.js:2 ConfigCat - ERROR - [1001] Failed to evaluate setting 'xxx_feature' (the key was not found in config JSON). Returning the defaultValue parameter that you specified in your application: 'false'. Available keys: ['yyy_feature'].

To reproduce

<ConfigCatProvider sdkKey={<sdkey1>}>
      .....
      <ConfigCatProvider sdkKey={<sdkey2>}>
          .....
      </ConfigCatProvider>
</ConfigCatProvider>

sdkey1 has a config with a feature flag X sdkey2 has a config with a feature flag Y

Expected behavior

I would like the provider to be isolated and support nesting.

Screenshots

If applicable, add screenshots to help explain your problem.

laliconfigcat commented 1 month ago

Hello @Amf1k ,

Thanks for reaching out. This issue is already on our backlog but we haven't started working on it. In the meantime I'd recommend you to use the React SDK only for one of your SDK keys and you can utilize the JS SDK for the other SDK key. I know it is not a perfect solution, but it can be a workaround for now.

Cheers, Lali

Amf1k commented 1 month ago

@laliconfigcat Hello,

Could you tell me approximately when the fix will be available?

Thanks for the answer.

laliconfigcat commented 1 month ago

I don't have an exact ETA for implementing this feature in the SDK. We'll keep you posted if we have any progress.

github-actions[bot] commented 1 day ago

This issue is marked stale because it has no activity in the last 3 weeks. The issue will be closed in one week. Please remove the stale flag to keep it open.