You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Last month Vercel introduced middleware in their latest version of Next.js version 12. The middleware is using edge functions on their hosting environment but when you self-host on example GKE it also works but the same limitations apply.
If I am using posthog-node I am getting the following error:
Error: Error: Request to api/feature_flag failed with error: adapter is not a function
at FeatureFlagsPoller._request (webpack-internal:///./node_modules/posthog-node/feature-flags.js:158:19)
at async FeatureFlagsPoller._loadFeatureFlags (webpack-internal:///./node_modules/posthog-node/feature-flags.js:91:25)
at async FeatureFlagsPoller.loadFeatureFlags (webpack-internal:///./node_modules/posthog-node/feature-flags.js:78:13)
at async FeatureFlagsPoller.isFeatureEnabled (webpack-internal:///./node_modules/posthog-node/feature-flags.js:36:9)
at async PostHog.isFeatureEnabled (webpack-internal:///./node_modules/posthog-node/index.js:255:16)
at async Object.middleware [as handler] (webpack-internal:///./src/pages/_middleware.ts:26:28)
at async adapter (webpack-internal:///./node_modules/next/dist/server/web/adapter.js:30:22)
at async DevServer.runMiddleware (/Users/weyertdeboer/Development/Projects/xxx/app/projects/project/node_modules/next/dist/server/next-server.js:438:26)
at async DevServer.runMiddleware (/Users/weyertdeboer/Development/Projects/xxx/app/projects/project/node_modules/next/dist/server/dev/next-dev-server.js:394:28)
at async Object.fn (/Users/weyertdeboer/Development/Projects/xxx/app/projects/project/node_modules/next/dist/server/next-server.js:817:34)
I think this due to the use of Axios which is using XMLHttpRequest and this is not supported by the middleware functionality or their edge functions. There is a similar ticket at Next.js discussing this issue: vercel/next.js#30932
I am wondering if it's worth it to rewrite the library in a different library that might use fetch instead my limited scan of the code Axios appears to be mostly used for:
retry functionality
exponential backoff when retrying
throw error for non-ok response
automatically handling of json responses
I am happy to raise a PR to make these changes if people at PostHog are happy with this
The text was updated successfully, but these errors were encountered:
Last month Vercel introduced middleware in their latest version of Next.js version 12. The middleware is using edge functions on their hosting environment but when you self-host on example GKE it also works but the same limitations apply.
If I am using
posthog-node
I am getting the following error:I think this due to the use of Axios which is using
XMLHttpRequest
and this is not supported by the middleware functionality or their edge functions. There is a similar ticket at Next.js discussing this issue: vercel/next.js#30932I am wondering if it's worth it to rewrite the library in a different library that might use
fetch
instead my limited scan of the code Axios appears to be mostly used for:I am happy to raise a PR to make these changes if people at PostHog are happy with this
The text was updated successfully, but these errors were encountered: