Repository navigation
Fix leak around different lifecycles of inbound vs outbound streams. - #691
Merged
Merged
Conversation
sukunrt
approved these changes
Apr 16, 2026
| for t, tmap := range p.topics { | ||
| if _, ok := tmap[pid]; ok { | ||
| delete(tmap, pid) | ||
| p.notifyLeave(t, pid) |
Member
There was a problem hiding this comment.
maybe these four statements should be a method.
q.Close()
delete(p.peers, pid)
p.clearPeerFromTopicsState(pid)
p.rt.RemovePeer(pid)
| in.s.Conn().RemotePeer(), in.s.Protocol()) | ||
| case incomingKindClosedStream: | ||
| p.onClosedIncomingStream( | ||
| in.s.Conn().RemotePeer(), in.s.Protocol()) |
Member
There was a problem hiding this comment.
Do we need the protocol in onClosedIncomingStream? in.s.Protocol()?
Contributor
Author
There was a problem hiding this comment.
It's nice symmetry, and lets you cleanup state associated with a specific gossipsub version. For example, if extensions is supported you need to clean up extensions state.
Of course you could just always clean up all state, but this seems a little clearer.
In certain cases peer state may be leaked if the state is created on incoming messages and only cleared when our outbound stream is closed.
MarcoPolo
force-pushed
the
marco/fix-leak-incoming-stream
branch
from
April 17, 2026 20:28
75e8d29 to
d8037f3
Compare
3 of 15 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In certain cases peer state may be leaked if the state is created on incoming messages and only cleared when our outbound stream is closed.