Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Commit

Permalink
fix: use unidirectional streams (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos authored Jun 3, 2020
1 parent 3d4fd92 commit ec82f5b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ class PubsubBaseProtocol extends EventEmitter {

const peer = this._addPeer(new Peer(peerInfo))

peer.attachConnection(stream)
this._processMessages(idB58Str, stream, peer)
}

Expand All @@ -196,7 +195,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)
}
Expand Down
2 changes: 2 additions & 0 deletions src/peer.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,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')
Expand Down

0 comments on commit ec82f5b

Please sign in to comment.