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);