Summary
network/libp2p_network.go:105-136 — SendMsgs opens a libp2p stream but never closes it. In contrast, sendMsg (line 166-186) properly calls defer s.Close(). Each call to SendMsgs leaks a stream, accumulating file descriptors and memory.
Severity
High — over time this exhausts connection resources, leading to inability to open new streams.
Suggested Fix
Add defer stream.Close() after the stream is opened, matching the pattern in sendMsg.
Related
SendMsgs also silently swallows serialization errors: when the for loop completes normally, the function returns nil at line 135, discarding any errors accumulated in resErr (line 125). The return should be resErr instead of nil.
Summary
network/libp2p_network.go:105-136—SendMsgsopens a libp2p stream but never closes it. In contrast,sendMsg(line 166-186) properly callsdefer s.Close(). Each call toSendMsgsleaks a stream, accumulating file descriptors and memory.Severity
High — over time this exhausts connection resources, leading to inability to open new streams.
Suggested Fix
Add
defer stream.Close()after the stream is opened, matching the pattern insendMsg.Related
SendMsgsalso silently swallows serialization errors: when theforloop completes normally, the function returnsnilat line 135, discarding any errors accumulated inresErr(line 125). The return should beresErrinstead ofnil.