Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

web-sdk: onContextChange not called for named provider #488

Closed
thomaspoignant opened this issue Jul 19, 2023 · 5 comments · Fixed by #491
Closed

web-sdk: onContextChange not called for named provider #488

thomaspoignant opened this issue Jul 19, 2023 · 5 comments · Fixed by #491
Assignees
Labels
bug Something isn't working

Comments

@thomaspoignant
Copy link
Member

thomaspoignant commented Jul 19, 2023

Observed behavior

I am not sure to understand how do you change the context for a named provider?

Let's say I am doing something like this :

await OpenFeature.setContext({targetingKey: 'foo'});
OpenFeature.setProvider('my-provider', provider);
const client = await OpenFeature.getClient('my-provider');
//...
await OpenFeature.setContext({targetingKey: 'bar'});

Expected Behavior

I was expecting the function onContextChange of the provider to be called when changing the context.
But when looking at the code

async setContext(context: EvaluationContext): Promise<void> {
const oldContext = this._context;
this._context = context;
await this._defaultProvider?.onContextChange?.(oldContext, context);
}

it seems that this function is called only for the default provider.

Is it something expected? Did I miss something to be sure that onContextChange is call on the provider.

@thomaspoignant thomaspoignant changed the title Title: "Issue: onContextChange not called for named provider in js client" Please note that the provided title is just a suggestion, and you can modify it based on the specific content and context of the GitHub issue. Web-sdk: onContextChange not called for named provider in js client Jul 19, 2023
@thomaspoignant thomaspoignant changed the title Web-sdk: onContextChange not called for named provider in js client web-sdk: onContextChange not called for named provider in js client Jul 19, 2023
@thomaspoignant thomaspoignant changed the title web-sdk: onContextChange not called for named provider in js client web-sdk: onContextChange not called for named provider Jul 19, 2023
@thomaspoignant thomaspoignant added the bug Something isn't working label Jul 19, 2023
@beeme1mr
Copy link
Member

Hey @thomaspoignant, I would also expect the SDK to call onContextChange on all registered providers. Looking at the code, it looks like an error would bubble up to the user if the context change method throws in a provider. Is that the functionality we want? @toddbaert, what do you think?

@toddbaert
Copy link
Member

Ya I agree this is a bug. Context is global in the static context, that's a clear case. I think this is just a bug that we missed when implementing the js-sdk.

@lukas-reining
Copy link
Member

lukas-reining commented Jul 21, 2023

I would start to implement this now.
Should this already be covering the whole static context spec change? I think at the first look it seems that there is not much to do for the spec update anyways.
What do you think @toddbaert @beeme1mr @thomaspoignant?

@beeme1mr
Copy link
Member

Hey @lukas-reining, yes, it should cover the static context change. That spec change should be merged today 😄

@lukas-reining
Copy link
Member

Looking at the code, it looks like an error would bubble up to the user if the context change method throws in a provider. Is that the functionality we want? @toddbaert, what do you think?

What do we do about this? @beeme1mr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants