Replies: 3 comments 14 replies
-
|
@MattIPv4 some clarification to confirm my understanding: If the "core" frontend is the only one that sets a provider for the root domain, and all the "micro/plugin" frontends (let's imagine one called "notifications" for this discussion) use only a domain that belongs to them (ie: var notificationsFlags = OpenFeature.getClient('notificiations') // this will work with the micro-frontends flags
var coreFlags = OpenFeature.getClient() // this will work with the "core" flagsIn this case, the micro-UI can access both flag sets (though they do have to have some knowledge about which client to use). |
Beta Was this translation helpful? Give feedback.
-
|
@MattIPv4 I need to think through this more. I understand the issue here, but I don't think this is the correct path forward as it pretty fundamentally changes some of the root SDK behaviours. What front-end framework are you using? I'm wondering if there is something more native to the front-end framework / React that we could implement to achieve the same behaviour. |
Beta Was this translation helpful? Give feedback.
-
|
I get the idea and understand, that even though you can use domains to separate providers, this does not prevent the accidental overwrites you describe @MattIPv4. One question I have is about |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
👋 Pulling this out of a discussion on Slack:
I'm working with the web SDK in a microfrontend world, which notably uses a singleton approach on
window. We've recently run into an issue where the core of the frontend is using the default domain for its OpenFeature usage, but then a microfrontend that was written by another team (or conceivably even an external third-party writing a frontend plugin) accidentally also used the default domain for their OpenFeature usage and, due to the global singleton nature of the web SKD, overwrote the provider + context that the frontend core had set.One option is potentially to allow for the global singleton behaviour to be opted out of, so that each microfrontend using OpenFeature creates a new instance of the SDK. While, on the surface, this does work to ensure that a microfrontend can't interfere with the frontend core, or another microfrontend, it also means that we can't allow microfrontends to rely on the default domain if they just want to read the flags that the frontend core has already evaluated -- we just want to prevent mutations of the default domain, while allowing reads still. Opting out of the singleton behaviour would also be something that only the frontend core itself could do, but it wouldn't be able to enforce it on the microfrontends, so there is still a risk two microfrontends both use the default domain and collide with each other.
So, the idea I'm proposing as a solution to this is a concept of allowing a domain's provider and/or context to be frozen within the SDK, preventing mutations of those:
With these in place, the SDK can keep track of which domains (including the default) have what frozen status for their provider + context, similar to the map it currently maintains of the providers themselves. It can then check against the map when the
OpenFeature.setProvider,OpenFeature.setContext,OpenFeature.clearContext, etc., methods are used to know if a mutation should be allowed.As a very rudimentary version of this, I put together https://github.com/grafana/grafana/pull/112515/files as a monkey-patch to the web SDK for our specific usage to try out what it'd look like to prevent mutations of the default domain's provider and context. Hopefully that helps visualise what this idea looks like / is trying to achieve.
Beta Was this translation helpful? Give feedback.
All reactions