diff --git a/swarm_dial.go b/swarm_dial.go index 054902e7f7d4c9ba8a94be059749f5fee89bd297..ffb7ab5e2c0b4db8f432f43b3cbbdcd1640ccaca 100644 --- a/swarm_dial.go +++ b/swarm_dial.go @@ -317,13 +317,14 @@ func (s *Swarm) dial(ctx context.Context, p peer.ID) (*Conn, error) { connC, dialErr := s.dialAddrs(ctx, p, goodAddrsChan) if dialErr != nil { logdial["error"] = dialErr.Cause.Error() - if dialErr.Cause == context.Canceled { - // always prefer the "context canceled" error. - // we rely on behing able to check `err == context.Canceled` + switch dialErr.Cause { + case context.Canceled, context.DeadlineExceeded: + // Always prefer the context errors as we rely on being + // able to check them. // // Removing this will BREAK backoff (causing us to // backoff when canceling dials). - return nil, context.Canceled + return nil, dialErr.Cause } return nil, dialErr }