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

[bug] Support Node v19's default Keep-Alive #455

Open
demipixel opened this issue Mar 1, 2023 · 4 comments
Open

[bug] Support Node v19's default Keep-Alive #455

demipixel opened this issue Mar 1, 2023 · 4 comments

Comments

@demipixel
Copy link

Describe the bug
After making enough requests, I get:

(node:31573) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit

To Reproduce

  1. Use Node v19 where Keep Alive is enabled by default
  2. Make 10 requests (say, just fetch a user)

Expected behavior
Error should not appear

Version

  • Node version: 19
  • Lib version: 1.14.2
  • MacOS Ventural 13.2

Additional context

The same socket gets reused in node v19. This means the same "close" handler gets added repeatedly.

My temporary solution is to force node to use a new socket for each request, but of course that's not ideal:

import https from 'https';

client = new TwitterApi(
    configHere,
    {
      httpAgent: new https.Agent({
        keepAlive: false,
      }),
    },
  );
@gbourne1
Copy link

gbourne1 commented Aug 8, 2023

Also an issue with Node 20.
Setting the keepAlive to false gives a lot of uncaught exceptions and issues uploading.

@ymittal
Copy link

ymittal commented Oct 9, 2023

Is there a resolution for this?

@PLhery
Copy link
Owner

PLhery commented Oct 9, 2023

Hello,
We are not actively maintaining this library anymore since it became X ; if someone wants to propose a PR, feel free and I'll accept it (as long as it makes sense).

@alkihis
Copy link
Collaborator

alkihis commented Oct 11, 2023

Hello,
I've made a workaround to cleanup socket listeners after a request is completed in 1.15.2 release, the "MaxListenersExceededWarning" message should not appear anymore.

Any other issue happening due to keep-alive (true or false) giving uncaught exceptions must be addressed in another issue if any.

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 a pull request may close this issue.

5 participants