node-modules / agentkeepalive

Support keepalive http agent.
MIT License
579 stars 57 forks source link

Number of opened sessions overflow maxSockets limitation after timeout #36

Closed pangorgo closed 8 years ago

pangorgo commented 8 years ago

I've encountered this problem on node 0.10.43 and using https. Immediately after timeout event being emited (ECONNRESET), close event is emited as well, so removeSocketfunction is called twice.

For one of them, socket is removed ad destroyed from socket pool, but for another one, socket is not found on sockets pool so it is not removed and destroyed. Regardless socket being present on socket pool, new socket is created unconditionally, which result in:

first call: 1 socket destroyed 1 socket created second call: 0 socket destroyed 1 socket created

After all, there is +1 socket opened after such events happen, there should be some maxSocket check condition before creating new socket.