diff options
author | Robert Nagy <robertnagy@Roberts-MacBook-Pro.local> | 2019-08-21 15:12:48 +0200 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2019-08-23 06:28:36 -0700 |
commit | f39ad8a91fe43a4bfc427915a5bf2b749f00c048 (patch) | |
tree | d033f738325ec1f19c63af9f770c2c75d58810da /test/parallel/test-http-agent-keepalive.js | |
parent | 4e188b3c63f0488be03a1f723b9b50720c76fed4 (diff) | |
download | android-node-v8-f39ad8a91fe43a4bfc427915a5bf2b749f00c048.tar.gz android-node-v8-f39ad8a91fe43a4bfc427915a5bf2b749f00c048.tar.bz2 android-node-v8-f39ad8a91fe43a4bfc427915a5bf2b749f00c048.zip |
http: fix event listener leak
Fixes: https://github.com/nodejs/node/issues/29239
PR-URL: https://github.com/nodejs/node/pull/29245
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'test/parallel/test-http-agent-keepalive.js')
-rw-r--r-- | test/parallel/test-http-agent-keepalive.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/test/parallel/test-http-agent-keepalive.js b/test/parallel/test-http-agent-keepalive.js index 5902c58679..8cfc568b1e 100644 --- a/test/parallel/test-http-agent-keepalive.js +++ b/test/parallel/test-http-agent-keepalive.js @@ -52,7 +52,7 @@ function get(path, callback) { port: server.address().port, agent: agent, path: path - }, callback); + }, callback).on('socket', common.mustCall(checkListeners)); } function checkDataAndSockets(body) { @@ -134,3 +134,12 @@ server.listen(0, common.mustCall(() => { })); })); })); + +// Check for listener leaks when reusing sockets. +function checkListeners(socket) { + assert.strictEqual(socket.listenerCount('data'), 1); + assert.strictEqual(socket.listenerCount('drain'), 1); + assert.strictEqual(socket.listenerCount('error'), 1); + // Sockets have onReadableStreamEnd. + assert.strictEqual(socket.listenerCount('end'), 2); +} |