http: avoid stream listeners on idle agent sockets
Merged
MC
4mo ago+67+67+01234567890123456789-13-13-01234567890123456789
Fixes: https://github.com/nodejs/node/issues/63989
The response-queue-poisoning guard added to idle http.Agent sockets used a public 'data' listener. That made node-fetch@2 observe socket.listenerCount('data') > 0 during response close and report false ERR_STREAM_PREMATURE_CLOSE errors.
This changes the idle-socket guard to use the socket handle's internal onread hook while the socket is in the free pool, restoring the normal stream read callback when the socket is reused. The guard still destroys sockets that receive unsolicited data while idle, but it no longer adds public stream listeners.