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

Issue with dependency #85

Open
phkundi opened this issue Apr 14, 2024 · 1 comment
Open

Issue with dependency #85

phkundi opened this issue Apr 14, 2024 · 1 comment

Comments

@phkundi
Copy link

phkundi commented Apr 14, 2024

Hi there. I recently posted about an issue I had on Stackoverflow and was advised to share it here as well. I am not 100% confident that Posthog was the source of the problem I had, but after updating my dependencies and removing Posthog, I was able to resolve my issue. As I'm not interested in reintroducing the error, I haven't verified that this issue is coming from Posthog but I figured it might be helpful to post this anyways.

Here's the info from my SO post:

I have a critial issue on my NextJS app where all of the requests to my API routes time out in production. It used to work perfectly up until recently but now my app is unusable (except for the static landing page). It's working perfectly in my local environment.

I'm using NextJS 14.0.1 with App Router; MongoDB + Mongoose

Here are the timed logs from a simple /api/lead endpoint (create a lead in DB)

  • MongoDB Connection: 880.541ms
  • Request JSON Parsing: 0.913ms
  • Finding Lead: 556.57ms
  • Sending Response: 1.31ms

When fetching this through postman, it still takes > 10 seconds for me to receive the response. Default timeout on Netlify / Vercel happens after 10 seconds.

Eventually, my console showed some useful information with the following error:

Compiling /api/auth/[...nextauth] ...
 ⚠ ./node_modules/.pnpm/debug@4.3.4_supports-color@9.4.0/node_modules/debug/src/node.js
Module not found: ESM packages (supports-color) need to be imported. Use 'import' to reference the package instead. https://nextjs.org/docs/messages/import-esm-externals

Import trace for requested module:
./node_modules/.pnpm/debug@4.3.4_supports-color@9.4.0/node_modules/debug/src/node.js
./node_modules/.pnpm/debug@4.3.4_supports-color@9.4.0/node_modules/debug/src/index.js
./node_modules/.pnpm/follow-redirects@1.15.6_debug@4.3.4/node_modules/follow-redirects/debug.js
./node_modules/.pnpm/follow-redirects@1.15.6_debug@4.3.4/node_modules/follow-redirects/index.js
./node_modules/.pnpm/axios@1.6.8/node_modules/axios/dist/node/axios.cjs
./node_modules/.pnpm/posthog-node@4.0.0/node_modules/posthog-node/lib/index.esm.js
./libs/posthog.js
./libs/next-auth.js
./app/api/auth/[...nextauth]/route.js

Like I said, I upgraded all of my dependencies and removed Posthog, and requests came through normally again. Not sure why this issue was only present in my production environment.

@aronedwards
Copy link

aronedwards commented May 30, 2024

Also seeing this issue with Posthog, suddenly began occurring but seems limited to serverless calls (using vercel)

Another issue that is causing additional big issues is the fact that featureFlagsRequestTimeoutMs does not seem to work.
running a setInterval I can see the function keeps running

let posthogClient: PostHog | null = null;

function PostHogClient() {
  if (!posthogClient && process.env.POSTHOG_API_KEY) {
    posthogClient = new PostHog(process.env.POSTHOG_API_KEY, {
      host: "https://eu.posthog.com",
      flushAt: 1,
      flushInterval: 0,
      requestTimeout: 3000,
      featureFlagsRequestTimeoutMs: 3000,
    });
  }
  return posthogClient;
}
...
const x = setInterval(() => {
      console.warn("SEC call");
    }, 1000);
const phClient = PostHogClient();
    if (!phClient) {
      return false;
    }
 const result = await phClient.isFeatureEnabled(featureID, id, {
      groups: {
        company: tenantKey,
      },
    });
    clearInterval(x);

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

2 participants