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

Retries persist forever if blocked by adblocker #1598

Open
chasegiunta opened this issue Dec 11, 2024 · 4 comments
Open

Retries persist forever if blocked by adblocker #1598

chasegiunta opened this issue Dec 11, 2024 · 4 comments
Labels
SDK Support General SDK issues rather than being related to a feature team

Comments

@chasegiunta
Copy link

chasegiunta commented Dec 11, 2024

I'm aware that using the reverse proxy might be a workaround to this, but at the same time, I think this should be addressed. I'd think this would be a configurable option in the client. Also, might be related, it looks like the retry param isn't being updated in these failed requests?

Firefox 2024-12-11 12 51 32

This is Firefox using the PrivacyBadger extension (I'm not a user myself, but we found out pretty quickly after deploying the JS client that a gigantic number of our users are themselves)

@chasegiunta chasegiunta changed the title Retires persist forever if blocked by adblocker Retries persist forever if blocked by adblocker Dec 11, 2024
@rafaeelaudibert
Copy link
Member

Hey, @chasegiunta! Are you sure posthog-js is retrying always the same request? Are the payloads exactly the same?

Also, would you mind calling posthog.debug() and showing me what's being logged to the console?

I can help you with that if you could share me a URL where I can see that behavior myself?

@rafaeelaudibert rafaeelaudibert added the SDK Support General SDK issues rather than being related to a feature team label Dec 11, 2024
@chasegiunta
Copy link
Author

Hey @rafaeelaudibert, thanks for getting back to me so quick! Unfortunately, we had to remove the frontend client from our live application for now.

Here's debug output
Firefox 2024-12-11 13 21 31

And here are some more requests.
Firefox 2024-12-11 13 26 52

I believe there's a few initial ones that are blocked, which seem fine, but the others that are repetitive at the bottom, all seem to be exactly the same. (all with retry_count=1 params) Firefox does not actually show a payload.

image image

@rafaeelaudibert
Copy link
Member

Yeah, it's not displaying the payload because this is the initial HEAD request, it's failing before we can actually POST the data. We'll investigate further, but I can't promise on a deadline, thank you!

@Julien-Marcou
Copy link

Julien-Marcou commented Dec 12, 2024

We had the same issue about a year ago, I think this ticket is talking about the same issue: #482
I guess it's something that could also happens if posthog's servers are down for whatever reason.

PostHog being blocked by an adblocker is not necessary a problem, until we want to do A-B testing on our entire platform using feature flags.

Because of the adblocker, the onFeatureFlags() callback would never be called, which means we were leaving our users on an infinite loading blank screen.
So we had to add a global timeout on our own, to fallback to a default feature flag value to resolve the blank screen issue.

It would be nice to have this behavior directly configurable within posthog, with something like a "max retry" or "timeout", and an error callback on the onFeatureFlags method:

// example
import posthog from 'posthog-js';

posthog.init(token, { retries: 3 });

posthog.onFeatureFlags({
  loaded: (flags, variants) => {
    // feature flags are properly loaded
  },
  error: () => {
   // fallback when we cannot load the feature flags
  },
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SDK Support General SDK issues rather than being related to a feature team
Projects
None yet
Development

No branches or pull requests

3 participants