Open zaynetro opened 7 months ago
Hi! It is impossible to close posthog.Client when feature flags are enabled and no requests to get all flags were made.
posthog.Client
What happens:
FeatureFlagsPoller.run
poller.loaded <- false
fetchNewFeatureFlags
<-poller.shutdown
Client.Close
GetFeatureFlags
poller.loaded
Minimal reproduction example:
package main import ( "fmt" "os" "github.com/posthog/posthog-go" ) func main() { client, err := posthog.NewWithConfig("123", posthog.Config{ PersonalApiKey: "123", }) if err != nil { fmt.Println("could not initialize posthog client", err) os.Exit(1) } // NOTE: Uncomment for things to start working // flags, err := client.GetFeatureFlags() // fmt.Println("Flags", flags, err) fmt.Println("Trying to close the client...") if err := client.Close(); err != nil { fmt.Println("Failed to close:", err) } fmt.Println("Client closed.") }
Hi! It is impossible to close
posthog.Client
when feature flags are enabled and no requests to get all flags were made.What happens:
FeatureFlagsPoller.run
startspoller.loaded <- false
infetchNewFeatureFlags
because nobody reads from that channel<-poller.shutdown
is never consumed hence blockingClient.Close
method here.GetFeatureFlags
at least once. It starts readingpoller.loaded
channel hereMinimal reproduction example: