client.go | 7 ++++++- diff --git a/client.go b/client.go index f8d70372b93fa4133ecda1f9a3ab4018c191759c..2d2a3fa7eac4dcdcd6f99668916201cd4e929665 100644 --- a/client.go +++ b/client.go @@ -521,8 +521,13 @@ conntrack.Entry{network, s.Addr().String(), addr}, "dial torrent client", 0, ) + // Try to avoid committing to a dial if the context is complete as it's + // difficult to determine which dial errors allow us to forget the connection + // tracking entry handle. if ctx.Err() != nil { - cte.Forget() + if cte != nil { + cte.Forget() + } resCh <- dialResult{} return }