From c6ba48de86c04cba1da95d07f646f63b4f40c901 Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Thu, 4 Jun 2020 10:06:17 +0200 Subject: [PATCH] fix: use unidirectional streams (#45) --- src/index.js | 2 -- src/peer.js | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 4429b65be1..79e2fc8705 100644 --- a/src/index.js +++ b/src/index.js @@ -178,7 +178,6 @@ class PubsubBaseProtocol extends EventEmitter { protocols: [protocol] })) - peer.attachConnection(stream) this._processMessages(idB58Str, stream, peer) } @@ -200,7 +199,6 @@ class PubsubBaseProtocol extends EventEmitter { try { const { stream } = await conn.newStream(this.multicodecs) peer.attachConnection(stream) - this._processMessages(idB58Str, stream, peer) } catch (err) { this.log.err(err) } diff --git a/src/peer.js b/src/peer.js index 2e764313a2..cedd418327 100644 --- a/src/peer.js +++ b/src/peer.js @@ -87,6 +87,8 @@ class Peer extends EventEmitter { this.conn = conn this.stream = pushable({ onEnd: () => { + // close readable side of the stream + this.conn.reset && this.conn.reset() this.conn = null this.stream = null this.emit('close')