Skip to content

feat(flags): Add a way to determine if local flags are cached #445

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 of 5 tasks
haacked opened this issue Apr 9, 2025 · 0 comments · Fixed by #447
Closed
1 of 5 tasks

feat(flags): Add a way to determine if local flags are cached #445

haacked opened this issue Apr 9, 2025 · 0 comments · Fixed by #447
Assignees
Labels
enhancement New feature or request nodejs

Comments

@haacked
Copy link
Contributor

haacked commented Apr 9, 2025

Is your feature request related to a problem?

When bringing up new servers, there's a small chance that the local evaluation endpoint is having an outage just as the servers are coming up with the posthog-node client. This will cause the clients to fallback to remote evaluation.

It would be handy to have a way to check if local feature flags have been cached so that can be reported to a load balancer.

Describe the solution you'd like

A new method (naming can be debated here):

function localEvaluationFlagsLoaded(): boolean {
    return this.featureFlags.length > 0
}

async function waitForLocalEvaluationReady(): Promise<boolean> {}

Describe alternatives you've considered

Considered a callback or event when local flags are loaded, but that wouldn't initiate a load and cache of local flag definitions.

Related sub-libraries

  • All of them
  • posthog-web
  • posthog-node
  • posthog-ai
  • posthog-react-native

Additional context

https://posthoghelp.zendesk.com/agent/tickets/28510

Thank you for your feature request – we love each and every one!

You're welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request nodejs
Projects
None yet
2 participants