Unleash/unleash-proxy-client-js

Update context does not fetch new flags

spiderhands opened this issue · 2 comments

If the refreshInterval is set to 0 and updateContext function is called, the data does not update.

public async updateContext(context: IMutableContext): Promise<void> {
    // Give the user a nicer error message when including
    // static fields in the mutable context object
    // @ts-ignore
    if (context.appName || context.environment) {
        console.warn(
            "appName and environment are static. They can't be updated with updateContext."
        );
    }
    const staticContext = {
        environment: this.context.environment,
        appName: this.context.appName,
    };
    this.context = { ...staticContext, ...context };
    if (this.timerRef) { // <--------- here is the problem
        await this.fetchToggles();
    }
}

I think we should consider a 'started' flag instead. The intention was that a updateContext call should not fetch toggles before the SDK is started. But I agree that you should not necessarily require it to actually have background polling enabled.

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.