From 4cc6a94df5ec8fff9e1498733c45ef9767ceb050 Mon Sep 17 00:00:00 2001 From: vyzo Date: Thu, 20 Jan 2022 23:44:42 +0200 Subject: [PATCH] release the stream scope if the conn fails to open a new stream --- swarm_conn.go | 1 + 1 file changed, 1 insertion(+) diff --git a/swarm_conn.go b/swarm_conn.go index 5099edde..77b2defb 100644 --- a/swarm_conn.go +++ b/swarm_conn.go @@ -199,6 +199,7 @@ func (c *Conn) NewStream(ctx context.Context) (network.Stream, error) { } ts, err := c.conn.OpenStream(ctx) if err != nil { + scope.Done() return nil, err } return c.addStream(ts, network.DirOutbound, scope)