node-twitter-api-v2
node-twitter-api-v2 copied to clipboard
[bug] Support Node v19's default Keep-Alive
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
- Use Node v19 where Keep Alive is enabled by default
- 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,
}),
},
);
Also an issue with Node 20. Setting the keepAlive to false gives a lot of uncaught exceptions and issues uploading.
Is there a resolution for this?
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).
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.