aboutsummaryrefslogtreecommitdiff
path: root/test/parallel/test-http-agent-keepalive.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/parallel/test-http-agent-keepalive.js')
-rw-r--r--test/parallel/test-http-agent-keepalive.js11
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);
+}