From e71f7af3f745178031319451d83e8cbeec49d18d Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 4 Nov 2019 19:45:09 +0000 Subject: [PATCH] feat(swarm): return unwrapped context deadline errors --- swarm_dial.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/swarm_dial.go b/swarm_dial.go index 054902e..ffb7ab5 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 } -- GitLab