From 588619b7cffd0f555b1bde4f053ca61658a8a34c Mon Sep 17 00:00:00 2001 From: Dreamacro Date: Fri, 11 Sep 2020 16:12:37 +0800 Subject: [PATCH] fix SSH client leak bug --- lib/ssh.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ssh.js b/lib/ssh.js index 50b3583..f650413 100644 --- a/lib/ssh.js +++ b/lib/ssh.js @@ -6,7 +6,7 @@ module.exports = function(opt) { var agent = new http.Agent(); agent.createConnection = function(options, fn) { - conn.on('ready', function() { + conn.once('ready', function() { conn.exec('docker system dial-stdio', function(err, stream) { if (err) { conn.end(); @@ -16,14 +16,14 @@ module.exports = function(opt) { fn(null, stream); - stream.on('close', () => { + stream.once('close', () => { conn.end(); agent.destroy(); }); }); }).connect(opt); - conn.on('end', () => agent.destroy()); + conn.once('end', () => agent.destroy()); }; return agent;