Commit f408b582 authored by metacertain's avatar metacertain Committed by GitHub

Close errorful but created streams (#383)

* Close errorful but created streams
parent 6160b927
......@@ -462,6 +462,10 @@ func (s *Service) newStreamForPeerID(ctx context.Context, peerID libp2ppeer.ID,
swarmStreamName := p2p.NewSwarmStreamName(protocolName, protocolVersion, streamName)
st, err := s.host.NewStream(ctx, peerID, protocol.ID(swarmStreamName))
if err != nil {
if st != nil {
s.logger.Debug("stream experienced unexpected early close")
_ = st.Close()
}
if err == multistream.ErrNotSupported || err == multistream.ErrIncorrectVersion {
return nil, p2p.NewIncompatibleStreamError(err)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment