aneilbaboo / replayer

Replay HTTP requests for testing Node.js / Javascript code
Apache License 2.0
33 stars 7 forks source link

Using keepalive causes MaxListenersExceededWarning: Possible EventEmitter memory leak detected #7

Closed aneilbaboo closed 7 years ago

aneilbaboo commented 7 years ago

Add a keepalive agent to the options of your http agent as in https://github.com/node-modules/agentkeepalive

Then run several test, and see:

This is due to the socket accumulating timeout listeners inside the realReq.on('socket',... code:

cache.js:333


      realReq.on('socket', function(socket) {
        socket.on('timeout', function() {
          timedOut = true;
        });
      });

Because the socket is reused, it keeps accumulating timeout listeners.