posthog-node icon indicating copy to clipboard operation
posthog-node copied to clipboard

AbortSignal is not defined

Open MooseSaeed opened this issue 2 years ago • 10 comments

I'm using Posthog node client in the backend of Nuxtjs app and I'm getting these errors in the console.

ERROR  AbortSignal is not defined                                                                                02:55:25

  at PostHogClient.<anonymous> (server.js:1570:17)
  at step (server.js:436:27)
  at Object.next (server.js:385:53)
  at server.js:378:71
  at new Promise (<anonymous>)
  at __awaiter (server.js:364:12)
  at PostHogClient.module.exports.../manifold/node_modules/posthog-node/lib/index.cjs.js.PostHogCore.fetchWithRetry (server.js:1567:16)
  at PostHogClient.<anonymous> (server.js:1314:52)
  at step (server.js:436:27)
  at Object.next (server.js:385:53)

It's a simple getAllFlags() attempt where i'm initializing the client in a Typescript Singleton object. It successfully returns the flags values on page load, but the problem is that I keep getting the above error on each page refresh.

MooseSaeed avatar Feb 07 '23 01:02 MooseSaeed

Hey @MooseSaeed it sounds like you're on node 14-, while AbortSignal is defined only in node 15+. I'll update the package node requirements 👀

neilkakkar avatar Feb 07 '23 10:02 neilkakkar

@neilkakkar Thanks for responding. I have upgraded node version to 16.13.1 and I'm still getting the error. Maybe the issue is associated with Typescript?

MooseSaeed avatar Feb 07 '23 12:02 MooseSaeed

Is it exactly the same error, or is it somewhat different? Mind removing and installing posthog-node from scratch to see if it persists?

neilkakkar avatar Feb 07 '23 12:02 neilkakkar

@neilkakkar No matter what I try, I get the same same error. I uninstalled and reinstalled posthog-node and I even cleaned out my lock file, but nothing appears to work for some reason. On the frontend, I'm using the javascript client, which works well, however the node client continues throwing these errors.

MooseSaeed avatar Feb 07 '23 18:02 MooseSaeed

if you have an outdated version of node this polyfill worked for us until we got the update done https://www.npmjs.com/package/abort-controller

Ruegen avatar May 15 '23 01:05 Ruegen

so this issue has been open for almost 1 year... yet it is still not fixed? c'mon guys @posthog-bot

StockBet avatar Dec 15 '23 20:12 StockBet

@StockBet do you have a reproducible example I can try out? I'm failing to reproduce this on node 15+

neilkakkar avatar Dec 20 '23 11:12 neilkakkar

What do you mean? How can I give you a reproducible example? my node is v20.4.0

Sent via Superhuman ( @.*** )

On Wed, Dec 20, 2023 at 6:37 AM, Neil Kakkar < @.*** > wrote:

@ StockBet ( https://github.com/StockBet ) do you have a reproducible example I can try out? I'm failing to reproduce this on node 15+

— Reply to this email directly, view it on GitHub ( https://github.com/PostHog/posthog-node/issues/82#issuecomment-1864326589 ) , or unsubscribe ( https://github.com/notifications/unsubscribe-auth/AVJW45ED4Q762ZIPKUDGYRDYKLEZHAVCNFSM6AAAAAAUTK63USVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNRUGMZDMNJYHE ). You are receiving this because you were mentioned. Message ID: <PostHog/posthog-node/issues/82/1864326589 @ github. com>

StockBet avatar Dec 20 '23 11:12 StockBet

A simple project setup where it doesn't work - node + posthog installation - a github repo link works :) - pretty hard to debug if I can't tell what might be going wrong

neilkakkar avatar Dec 20 '23 11:12 neilkakkar

I finally figured out the issue. @neilkakkar

Turns out Render (which I use to deploy my node server) uses 14.17.0 by default for some reason.

StockBet avatar Dec 20 '23 18:12 StockBet