From 0ca2e63590afe2c16957c979b18550655742007f Mon Sep 17 00:00:00 2001 From: Alexey Orlenko Date: Mon, 20 Feb 2017 20:28:02 +0200 Subject: [PATCH] connection: close connection on transport error This commit forces a connection to close if a transport emits error. Socket-related errors should have been already doing this, but parse errors just emitted error events that caused the invalid chunk to be parsed over and over again if the event was intercepted. Refs: https://github.com/metarhia/JSTP/issues/76 PR-URL: https://github.com/metarhia/JSTP/pull/78 --- lib/connection.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/connection.js b/lib/connection.js index 4eabd309..ed6407ee 100644 --- a/lib/connection.js +++ b/lib/connection.js @@ -309,6 +309,7 @@ Connection.prototype._onSocketClose = function() { // error - error that has occured // Connection.prototype._onSocketError = function(error) { + this._end(); this.emit('error', error, this); };