Skip to content

fix: do not propagate unrelated changes to other envs#11660

Open
gastonfournier wants to merge 4 commits intomainfrom
fix/event-propagation
Open

fix: do not propagate unrelated changes to other envs#11660
gastonfournier wants to merge 4 commits intomainfrom
fix/event-propagation

Conversation

@gastonfournier
Copy link
Contributor

@gastonfournier gastonfournier commented Mar 20, 2026

About the changes

This fixes a bug in delta / streaming propagation where a feature change in one environment could produce a feature-updated event in other connected environments, even when those environments had no in-scope change.

The issue was in ClientFeatureToggleDelta.updateFeaturesDelta(). It built one global set of changed feature names for the revision window and then, for every connected environment, reloaded those feature names in that environment and emitted feature-updated events.

That meant a change in production could cause a client streaming development to receive:

  • a new eventId
  • a feature-updated payload containing the current development state
  • no actual change for the subscribed environment

So, from the client's point of view, this looked like a no-op update with a bumped revision.

This PR narrows feature refreshes by environment before reloading toggles:

  • environment-specific events only refresh the matching connected environment
  • environment-agnostic events still apply to all environments
  • segment and removal behavior stay unchanged

I also added a regression test covering the case where a production-only feature update must not emit a synthetic development delta event.

Discussion points

This is intentionally the smaller correctness fix.

A possible follow-up would be to precompute affected environments and skip unaffected delta caches entirely, but that is not required to fix the incorrect payload propagation described above.

Copilot AI review requested due to automatic review settings March 20, 2026 07:40
@github-actions
Copy link
Contributor

@gastonfournier, core features have been modified in this pull request. Please review carefully!

@github-actions
Copy link
Contributor

github-actions bot commented Mar 20, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None
Copy link
Contributor

Copilot AI left a comment

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 adjusts the client feature toggle delta generation to avoid producing (and serving) deltas for environments that were not affected by a given change event, preventing unrelated environment updates from causing “no-op” deltas elsewhere.

Changes:

  • Add environment-aware filtering when computing which feature toggles need to be refreshed per environment during delta updates.
  • Remove the single cross-environment featuresUpdated list in favor of an environment-specific list computed inside the update loop.
  • Add a unit test asserting that an update in one environment does not produce a delta for a different environment.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/lib/features/client-feature-toggles/delta/client-feature-toggle-delta.ts Filters updated feature names per environment when refreshing delta caches.
src/lib/features/client-feature-toggles/delta/client-feature-toggle-delta.test.ts Adds regression test to ensure unrelated environment changes don’t yield deltas.

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

@github-actions
Copy link
Contributor

API Changelog 7.5.1 vs. 7.5.1

No changes

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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


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

@gastonfournier gastonfournier moved this from New to In Progress in Issues and PRs Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants