From fa0f8397fcef41213f240588b4aab4a1948ff08a Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Wed, 3 Jun 2020 14:45:00 +0200 Subject: [PATCH] fix: use unidirectional streams --- 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 4429b65..79e2fc8 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 2e76431..16bd816 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.source.end && this.conn.source.end() this.conn = null this.stream = null this.emit('close')