From 185aaa7184104ec49074ca12bca9906bd21009ef Mon Sep 17 00:00:00 2001 From: Tony Chen Date: Tue, 18 Oct 2022 21:36:06 +0800 Subject: [PATCH] fix net error (#2460) --- selector/node/ewma/node.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/selector/node/ewma/node.go b/selector/node/ewma/node.go index 4fed4aaa2..46d5c41cc 100644 --- a/selector/node/ewma/node.go +++ b/selector/node/ewma/node.go @@ -4,6 +4,7 @@ import ( "container/list" "context" "math" + "net" "sync" "sync/atomic" "time" @@ -158,8 +159,9 @@ func (n *Node) Pick() selector.DoneFunc { if n.errHandler != nil && n.errHandler(di.Err) { success = 0 } + var netErr net.Error if errors.Is(context.DeadlineExceeded, di.Err) || errors.Is(context.Canceled, di.Err) || - errors.IsServiceUnavailable(di.Err) || errors.IsGatewayTimeout(di.Err) { + errors.IsServiceUnavailable(di.Err) || errors.IsGatewayTimeout(di.Err) || errors.As(di.Err, netErr) { success = 0 } }