From 4077178b3f41f5473f5e1399670d9563ffbd8a88 Mon Sep 17 00:00:00 2001 From: Vratislav Kalenda Date: Wed, 4 Apr 2018 22:07:12 +0200 Subject: [PATCH] fix: end stream in connection.end --- lib/connection.js | 1 + test/unit/connection/outbound-sending-tests.js | 1 + test/unit/test-helper.js | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/lib/connection.js b/lib/connection.js index 0fb874cf5..6e9f22eab 100644 --- a/lib/connection.js +++ b/lib/connection.js @@ -328,6 +328,7 @@ Connection.prototype.end = function() { this.writer.add(emptyBuffer); this._ending = true; this._send(0x58); + this.stream.end(); }; Connection.prototype.close = function(msg, more) { diff --git a/test/unit/connection/outbound-sending-tests.js b/test/unit/connection/outbound-sending-tests.js index 3dde8a3cb..02dff60ee 100644 --- a/test/unit/connection/outbound-sending-tests.js +++ b/test/unit/connection/outbound-sending-tests.js @@ -183,6 +183,7 @@ test('sends end command', function() { con.end(); var expected = new Buffer([0x58, 0, 0, 0, 4]); assert.received(stream, expected); + assert.equal(stream.closed, true); }); test('sends describe command',function() { diff --git a/test/unit/test-helper.js b/test/unit/test-helper.js index 878898d8b..b160722a2 100644 --- a/test/unit/test-helper.js +++ b/test/unit/test-helper.js @@ -15,8 +15,13 @@ p.write = function(packet) { this.packets.push(packet); }; +p.end = function() { + p.closed = true; +} + p.setKeepAlive = function(){}; +p.closed = false; p.writable = true; createClient = function() {