Repository navigation
fix(flags): request flags /flags already returned without waiting on other callers - #260
Conversation
posthog-elixir Compliance ReportDate: 2026-11-20T09:10:00.141751+00:00 ✅ All Tests Passed!47/47 tests passed Capture Tests✅ 30/30 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
|
There was a problem hiding this comment.
PostHog Review · Standard · reviewed 3a45676: 1 Should fix.
See this review and its findings in PostHog Review. Comment @posthog review --deep for a Deep review. A Deep review takes longer and looks deeper than a Standard review.
dustinbyrne
left a comment
There was a problem hiding this comment.
The exact-capacity fix now clears stale presence, and the known-present fast path still works. The same fix can also erase the return history that protects against an older omission; I reproduced a skipped /flags request that would have returned the flag. The mixed-scope refresh finding also still reproduces. Consider keeping presence separate from ordering history, rechecking key state after a wait, and aligning the transition with PostHog/sdk-specs#231 before release.
AI-assisted review.
ioannisj
left a comment
There was a problem hiding this comment.
🤖 An AI agent wrote this on behalf of @ioannisj.
Nothing from me, this looks good. The known-present path matches the positive-knowledge rule in the evaluate-flags spec, and the later coordination rounds stay under the one shared deadline.
💡 Motivation and Context
Follows @dustinbyrne's suggestion on #259: #259 (comment)
#258 coordinates
evaluate_flagsrequests for flags that aren't in the local definitions, so concurrent callers share one/flagsexistence check. The SDK already remembers keys that/flagscleanly said don't exist. It did not use the fact that/flagsreturned a key. Those keys still went through coordination, so a caller could wait up to 2 seconds behind another caller's in-flight request, even though the flag was known to exist and each caller needs its own/flagsresult anyway.This is common for flags created since the last definitions poll. Every new batch of callers for such a flag waited behind one request.
Changes
Each flag key now has one of three states until the next definitions refresh:
/flagsresponse omitted the key. Evaluations skip the request, as before./flagsresponse returned the key. Evaluations make their own/flagsrequest directly, without coordinating.Notes:
/flagsrequest for its own context.evaluate_flagsdocs mention the new behavior.💚 How did you test it?
mix credo --strictpass.missing_key_knowledge_test.exsfailed before the change:/flagsalready returned makes its request while another caller's request for that key is still in flight.📝 Checklist
If releasing new changes
sampo addto generate a changeset fileSpec
PostHog/sdk-specs#231 is being updated to allow SDKs to remember confirmed-present keys and skip coordination for them.
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
/flagsreturns errors. This change is small and helps every later batch of callers for a flag that exists.