Commit e71f7af3 authored by Steven Allen's avatar Steven Allen

feat(swarm): return unwrapped context deadline errors

parent f4bb4313
...@@ -317,13 +317,14 @@ func (s *Swarm) dial(ctx context.Context, p peer.ID) (*Conn, error) { ...@@ -317,13 +317,14 @@ func (s *Swarm) dial(ctx context.Context, p peer.ID) (*Conn, error) {
connC, dialErr := s.dialAddrs(ctx, p, goodAddrsChan) connC, dialErr := s.dialAddrs(ctx, p, goodAddrsChan)
if dialErr != nil { if dialErr != nil {
logdial["error"] = dialErr.Cause.Error() logdial["error"] = dialErr.Cause.Error()
if dialErr.Cause == context.Canceled { switch dialErr.Cause {
// always prefer the "context canceled" error. case context.Canceled, context.DeadlineExceeded:
// we rely on behing able to check `err == context.Canceled` // Always prefer the context errors as we rely on being
// able to check them.
// //
// Removing this will BREAK backoff (causing us to // Removing this will BREAK backoff (causing us to
// backoff when canceling dials). // backoff when canceling dials).
return nil, context.Canceled return nil, dialErr.Cause
} }
return nil, dialErr return nil, dialErr
} }
......
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