MCPcopy Index your code
hub / github.com/coder/coder / isRetryableError

Function isRetryableError

cli/ssh.go:71–88  ·  view source on GitHub ↗

isRetryableError checks for transient connection errors worth retrying: DNS failures, connection refused, and server 5xx.

(err error)

Source from the content-addressed store, hash-verified

69// isRetryableError checks for transient connection errors worth
70// retrying: DNS failures, connection refused, and server 5xx.
71func isRetryableError(err error) bool {
72 if err == nil || xerrors.Is(err, context.Canceled) {
73 return false
74 }
75 // Check connection errors before context.DeadlineExceeded because
76 // net.Dialer.Timeout produces *net.OpError that matches both.
77 if codersdk.IsConnectionError(err) {
78 return true
79 }
80 if xerrors.Is(err, context.DeadlineExceeded) {
81 return false
82 }
83 var sdkErr *codersdk.Error
84 if xerrors.As(err, &sdkErr) {
85 return sdkErr.StatusCode() >= 500
86 }
87 return false
88}
89
90// retryWithInterval calls fn up to maxAttempts times, waiting
91// interval between attempts. Stops on success, non-retryable

Callers 2

TestIsRetryableErrorFunction · 0.85
retryWithIntervalFunction · 0.85

Calls 4

StatusCodeMethod · 0.95
IsConnectionErrorFunction · 0.92
AsMethod · 0.80
IsMethod · 0.45

Tested by 1

TestIsRetryableErrorFunction · 0.68