-
Notifications
You must be signed in to change notification settings - Fork 127
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
Posthog Node or Posthog JS for edge runtime #1522
Comments
For a server side runtime you definitely want posthog node. The JS SDK is very much so designed around the browser. |
@benjackwhite I'm calling This happened many times earlier today, but here are two specific logs I captured (shutdown is called right after each log):
Other details:
|
Thanks for the extra context. I couldn't find anything in our logs around timeouts or ingest issues around those times so its unclear what could have caused it. I know the way the code works it will respect the shutdown time but not perfectly. It just checks after each flush to see if the timeout has been reached. If the http call for the flush timesout in a weird way though then it could for sure just hold way too long. I'll take a look and see if there is anything that can be made clearer there. I'm still a bit lost however as to why the fetch calls would be hanging given our server logs around those times look very good. It might be better to make the shutdown call respect the timeout, regardless of what is happening in the background. I'll see about making that change |
Got a PR here to respect the timeout forcefully PostHog/posthog-js-lite#305 Doesn't answer the question as to why this might be happening though. One step at a time. |
Cool, this affects Posthog node too right? Also, in my case should shutdown be redundant/noop, because the client configs say to flush every event? I don't see how I can truly ensure flushing without having some kind of |
Yeah the linked PR is the repo that powers a few JS based libs including posthog-node. The reason the shutdown is needed is the flushing happens in the background. Shutdown is designed to gather up all in progress flushes, await them and flush in a loop if necessary. So it is only a no-op if the previous background flush occurred reliably. If you are using shutdown its actually recommended not to reduce the flush configs as the shutdown takes care of it nicer. |
Got it, thanks! |
I'm running a NextJS app on Cloudflare, which only supports edge runtime. I'm currently using Posthog Node and experiencing some issues with
await client.shutdown
hanging in prod. Is it recommended I use Posthog JS for edge runtime?The text was updated successfully, but these errors were encountered: