feat(feature-flags): support early_exit in posthog-node local evaluation#3705
Draft
gustavohstrassburger wants to merge 1 commit into
Draft
feat(feature-flags): support early_exit in posthog-node local evaluation#3705gustavohstrassburger wants to merge 1 commit into
gustavohstrassburger wants to merge 1 commit into
Conversation
…ode local evaluation Generated-By: PostHog Code Task-Id: 5c8c17e3-25d4-412f-a073-82460e76d7ee
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Contributor
|
Size Change: +482 B (0%) Total Size: 16.4 MB
ℹ️ View Unchanged
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
PostHog/posthog#57321 added an early exit option to feature flags: when enabled, condition evaluation stops and returns
falseas soon as a user matches a group's targeting but is excluded by its rollout percentage, instead of falling through to later groups. That PR implemented the behavior server-side (Rust engine), butposthog-node's local evaluation re-implements the matching loop in TypeScript and did not honor the newfilters.early_exitfield — so locally-evaluated flags could diverge from server-side results.Changes
early_exit?: booleanto the feature-flagfilterstype.OutOfRolloutBoundcase), returnfalseimmediately rather than evaluating later groups. Property mismatches still fall through, mirroring the Rust semantics exactly.The
/flags/definitionsendpoint already returnsfilters.early_exit(the serializer dumps the fullfiltersdict verbatim), so no SDK fetch/parse changes were needed.Release info Sub-libraries affected
Libraries affected
Checklist
If releasing new changes
pnpm changesetto generate a changeset fileHow did you test this code?
Added unit tests in
feature-flags.spec.tscovering early-exit enabled (returnsfalsewithout evaluating later groups), default/unset (falls through to a later matching group), and a property-mismatch case (does not early exit). Fullposthog-nodesuite passes (586 tests); lint and build are clean.Created with PostHog Code