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
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos committed Jun 3, 2020
1 parent 508a632 commit fa0f839
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 {
protocols: [protocol]
}))

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

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

0 comments on commit fa0f839

Please sign in to comment.