Skip to content

Commit

Permalink
fix: handle closing outbound stream (#314)
Browse files Browse the repository at this point in the history
  • Loading branch information
twoeths authored Aug 8, 2022
1 parent 5e6ce1f commit 74c08b1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2736,6 +2736,8 @@ export class GossipSub extends EventEmitter<GossipsubEvents> implements Initiali
metrics.cacheSize.set({ cache: 'fanout' }, this.fanout.size)
// Bounded by peer
metrics.cacheSize.set({ cache: 'peers' }, this.peers.size)
metrics.cacheSize.set({ cache: 'streamsOutbound' }, this.streamsOutbound.size)
metrics.cacheSize.set({ cache: 'streamsInbound' }, this.streamsInbound.size)
metrics.cacheSize.set({ cache: 'acceptFromWhitelist' }, this.acceptFromWhitelist.size)
metrics.cacheSize.set({ cache: 'gossip' }, this.gossip.size)
metrics.cacheSize.set({ cache: 'control' }, this.control.size)
Expand Down
2 changes: 2 additions & 0 deletions src/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export class OutboundStream {

close(): void {
this.closeController.abort()
// similar to pushable.end() but clear the internal buffer
this.pushable.return()
this.rawStream.close()
}
}
Expand Down

0 comments on commit 74c08b1

Please sign in to comment.