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

fix: Axios issue in Cloudflare workers #132

Merged
merged 7 commits into from
Dec 5, 2023

Conversation

benjackwhite
Copy link
Collaborator

@benjackwhite benjackwhite commented Dec 4, 2023

Problem

Hopefully fixes #127
And also #129

Changes

The current version of Axios fixes a security issue but has other issues regarding environments like Cloudflare.
Tried to look for a general fix here but the world of polyfilled Fetch is a mess to say the least... In the end, the workaround that made most sense was to simply use fetch if it is defined (which it is in custom environments like Cloudflare workers.

Also added an example project for testing this - managed to recreate the issue and this PR fixes it.

Release info Sub-libraries affected

Bump level

  • Major
  • Minor
  • Patch

Libraries affected

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

Changelog notes

  • Fixes issues with Axios imports for non-node environments like Cloudflare workers
  • Uses the globally defined fetch if available, otherwise imports and uses axios as a polyfill

@benjackwhite benjackwhite marked this pull request as ready for review December 4, 2023 12:09
Copy link
Member

@pauldambra pauldambra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't run it but looks good to me...

a few nit-picks that are very not-blocking

examples/example-cloudflare/src/index.ts Outdated Show resolved Hide resolved
posthog-node/src/fetch.ts Show resolved Hide resolved
posthog-node/test/feature-flags.spec.ts Show resolved Hide resolved
@benjackwhite benjackwhite merged commit ac3f27d into master Dec 5, 2023
3 checks passed
@benjackwhite benjackwhite deleted the fix/axios-cloudflare-issue branch December 5, 2023 15:23
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

Successfully merging this pull request may close these issues.

Axios upgrade breaks non-Node runtimes
3 participants