Skip to content

Commit c6ba48d

Browse files
authored
fix: use unidirectional streams (#45)
1 parent bcadfef commit c6ba48d

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/index.js

-2
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ class PubsubBaseProtocol extends EventEmitter {
178178
protocols: [protocol]
179179
}))
180180

181-
peer.attachConnection(stream)
182181
this._processMessages(idB58Str, stream, peer)
183182
}
184183

@@ -200,7 +199,6 @@ class PubsubBaseProtocol extends EventEmitter {
200199
try {
201200
const { stream } = await conn.newStream(this.multicodecs)
202201
peer.attachConnection(stream)
203-
this._processMessages(idB58Str, stream, peer)
204202
} catch (err) {
205203
this.log.err(err)
206204
}

src/peer.js

+2
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ class Peer extends EventEmitter {
8787
this.conn = conn
8888
this.stream = pushable({
8989
onEnd: () => {
90+
// close readable side of the stream
91+
this.conn.reset && this.conn.reset()
9092
this.conn = null
9193
this.stream = null
9294
this.emit('close')

0 commit comments

Comments
 (0)