fix: Buffer feature-flag subscribers registered before init#2267
Merged
charlesvien merged 2 commits intoMay 21, 2026
Merged
Conversation
Member
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Contributor
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
apps/code/src/renderer/utils/analytics.ts:56-59
After the drain loop, every pre-init listener remains in `pendingFlagListeners` for the entire lifetime of the component — so the Set holds a reference in parallel with posthog's own internal listener list. Clearing the Set after draining frees that duplicate reference early; the cleanup closure still works correctly because `listener.unsubscribe?.()` handles the posthog unsubscription, and `pendingFlagListeners.delete(listener)` gracefully no-ops on a missing key.
```suggestion
for (const listener of pendingFlagListeners) {
listener.unsubscribe = posthog.onFeatureFlags(listener.callback);
}
pendingFlagListeners.clear();
}
```
Reviews (1): Last reviewed commit: "Buffer feature-flag subscribers register..." | Re-trigger Greptile |
This was referenced May 20, 2026
a29daf7 to
070c9bf
Compare
cdcae3d to
333b7f9
Compare
This was referenced May 20, 2026
Base automatically changed from
05-19-add_nightly_cleanup_of_stale_draft_releases
to
main
May 20, 2026 23:34
333b7f9 to
4e41951
Compare
4e41951 to
6261888
Compare
6261888 to
becc21c
Compare
tatoalo
approved these changes
May 21, 2026
Member
Author
Merge activity
|
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
useFeatureFlagcallers that mount before App's init useEffect runs subscribe viaonFeatureFlagsLoadedwhile PostHog is uninitialized, so the no-op return silently drops the subscription. When flags later resolve, nothing fires and the hook stays stuck on its initial value for the rest of the session.Closes #2123
Changes
How did you test this?
Manually
Publish to changelog?