Skip to content
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

Bug: In Webworker posthog-js has wrong values for Feature Flags and onFeatureFlags is called in a loop #1392

Open
Dario91 opened this issue Aug 29, 2024 · 0 comments

Comments

@Dario91
Copy link

Dario91 commented Aug 29, 2024

Issue Description


I am attempting to use PostHog feature flags within a WebWorker. However, when I try to access a feature flag (e.g., ab-checklist), the PostHog JavaScript API returns an incorrect value.

Additionally, when I use the posthog.onFeatureFlags() method, it triggers an endless loop, continuously returning the wrong value for the feature flag.

This issue only occurs when a Release Condition is specified (as shown in the screenshot below). If I remove the Release Condition, the correct value is returned, but the loop still persists.

Posthog Config Screenshot and Repo for reproducing issue:

https://github.com/Dario91/posthog_issue2

Reademe.md with screenshots:
https://github.com/Dario91/posthog_issue2/blob/master/readme.md


Steps to Reproduce

  1. Install the required dependencies by running the following command:

    npm install
  2. Add your PostHog key and UserID in the env.ts file.

  3. Start the application with:

    npm start

If you open the console, you should notice that the logs in worker.ts (line 27) are being called repeatedly.

This issue does not occur in the main thread (index.ts); it only appears in the WebWorker thread. Additionally, the values logged are incorrect. They are correct the first time the onFeatureFlags callback is triggered but then get overwritten with incorrect values.

I expect to receive the value test from PostHog, but instead, I am getting either control or false.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant