Skip to content

clear flags when changing groups mid-session - #3270

Open
danoswaltCL wants to merge 1 commit into
release/6.6from
bugfix/ts-client-clear-flags-on-config-change
Open

clear flags when changing groups mid-session#3270
danoswaltCL wants to merge 1 commit into
release/6.6from
bugfix/ts-client-clear-flags-on-config-change

Conversation

@danoswaltCL

Copy link
Copy Markdown
Collaborator

#3267 this will unblock some work clc is trying to do, the ts client lib has a method for changing the groups that get sent with feature-flags, where a different set of groups could potentially fetch different flags. it had a bug though in that it doesn't clear previously fetched flags, so it always returned the flags for the original set of groups used. this now just clears the previous flags so that we'll successfully refetch.

@danoswaltCL
danoswaltCL requested review from bcb37 and a lite review from Copilot August 6, 2026 13:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug in the JS client SDK where changing feature-flag session groups mid-session would continue returning feature flags cached for the previous group set, preventing correct refetching for the new groups.

Changes:

  • Clear the in-memory feature flag cache whenever setFeatureFlagUserGroupsForSession() is called so subsequent flag reads refetch against the updated groups.
  • Add/expand unit tests to verify cache invalidation behavior and refetching after group changes.
  • Add a small DataService API (clearFeatureFlags) to support explicit cache invalidation.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
clientlibs/js/src/UpGradeClient/UpgradeClient.ts Clears cached feature flags when session groups are updated; ensures getAllFeatureFlags() refetches after group changes.
clientlibs/js/src/UpGradeClient/UpgradeClient.spec.ts Adds tests asserting cache clearing and that the next getAllFeatureFlags() call refetches after group changes.
clientlibs/js/src/DataService/DataService.ts Introduces clearFeatureFlags() to explicitly invalidate the feature flag cache.
clientlibs/js/src/DataService/DataService.spec.ts Adds coverage for clearFeatureFlags() clearing previously cached flags.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bcb37 bcb37 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Are we not caching per user/groups? Shouldn't it be the default behavior to refetch flags when user info has changed?
  2. Do we need to make this change in the Java client lib too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants