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: posthog.on('error') always catches http fetch error #180

Closed
1 of 4 tasks
L03TJ3 opened this issue Feb 13, 2024 · 9 comments · Fixed by #181
Closed
1 of 4 tasks

Bug: posthog.on('error') always catches http fetch error #180

L03TJ3 opened this issue Feb 13, 2024 · 9 comments · Fixed by #181
Labels
bug Something isn't working react-native

Comments

@L03TJ3
Copy link

L03TJ3 commented Feb 13, 2024

Bug description

We added a logger to catch whenever posthog failed to load at all. It seems posthog.on('error') should be used for this.
There is an initial HTTP fetch error always logged and catched, even if the calls to host are succesfull.

How to reproduce

  1. Not sure. pretty straigh-forward implementation where we only use getFeatureFlag(s)
  2. when relying on the default where sendFeatureFlagEvent is enabled, the .on('error') always triggers after default retry's and timeouts

Related sub-libraries

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

Additional context

  1. we use a reverse proxy
  2. it seems to be triggered once sendFeatureFlagEvent is enabled. disabling this and I don't catch a fetch error (which it is by default)

Thank you for your bug report – we love squashing them!

@sirpy
Copy link

sirpy commented Feb 14, 2024

Also i've noticed that the fetch error is:

  1. displayed with error code 0 (ie not an http error code)
  2. I've noticed it happens when moving to another tab and going back
  3. it doesnt seem to generate any network calls

@marandaneto
Copy link
Member

Hi @sirpy thanks for reporting this, let me check it.

@marandaneto
Copy link
Member

marandaneto commented Feb 14, 2024

@sirpy or @L03TJ3 can you enable debug and check the console logs? what is the error about? is there any more info either before or after the error? are you using PostHog self-hosted or the EU or US cloud? what is your api_host?

Do first thing after the SDK is init:
posthog.debug(false)

I cannot reproduce it locally so I'm not sure what it can be.

@marandaneto marandaneto added react-native question Further information is requested and removed bug Something isn't working labels Feb 14, 2024
@sirpy
Copy link

sirpy commented Feb 15, 2024

@marandaneto
We are using your service I believe US cloud. we use vercelrp.gooddollar.org as a reverse proxy to your api host.
Also notice that we are using the posthog react native in browser env.

@marandaneto
Copy link
Member

Screenshot 2024-02-15 at 11 35 23

I can reproduce it using RN Web, will check it out, thanks.

@marandaneto marandaneto added bug Something isn't working and removed question Further information is requested labels Feb 15, 2024
@marandaneto
Copy link
Member

It's not really because of sendFeatureFlagEvent, if you call posthog.capture('test'); you can reproduce that already, it just happens that sendFeatureFlagEvent=true captures an event when feature flags are used.

@marandaneto
Copy link
Member

If you init the SDK with captureMode: 'json', this does not happen either, but its form by default.

@marandaneto
Copy link
Member

Removing this, the error stops.
Using this flag as defined here, the status is always 0, so the error will be thrown here.

@marandaneto
Copy link
Member

https://github.com/PostHog/posthog-js-lite/releases/tag/posthog-react-native-v2.11.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working react-native
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants