From 78d764f7a224a3b4c59c69ed380b7c92948ac088 Mon Sep 17 00:00:00 2001 From: Dmytro Nechai Date: Wed, 23 Aug 2017 20:28:23 +0300 Subject: [PATCH] lib: fix connection restore PR-URL: https://github.com/metarhia/jstp/pull/289 Reviewed-By: Denys Otrishko Reviewed-By: Mykola Bilochub --- lib/session.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/session.js b/lib/session.js index d36fe56d..c10a3ab4 100644 --- a/lib/session.js +++ b/lib/session.js @@ -83,7 +83,9 @@ class Session extends Map { } _restore(newConnection, receivedCount) { - this.connection.close(); + if (this.connection) { + this.connection.close(); + } this.connection = newConnection; for (let i = this.guaranteedDeliveredCount + 1; i <= receivedCount; i++) { this.buffer.delete(i);