From 96890a304b725e134cb0afa7b80c8dc7e1b5c81e Mon Sep 17 00:00:00 2001 From: Jon Johnson <113393155+jonathanj-square@users.noreply.github.com> Date: Wed, 10 Jul 2024 10:42:17 -0700 Subject: [PATCH] fix: retryable streaming server errors to be logged as debug (#2019) fixes #2002 unexpected warnings caused by retryable errors - retryable errors will continue to be reported as debug. --- internal/rpc/rpc.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/internal/rpc/rpc.go b/internal/rpc/rpc.go index a96a3ec77..61c443bc7 100644 --- a/internal/rpc/rpc.go +++ b/internal/rpc/rpc.go @@ -240,7 +240,7 @@ func RetryStreamingServerStream[Req, Resp any]( } else { // Stream terminated; check if this was caused by an error err = stream.Err() - logLevel = log.Warn + logLevel = logLevelForError(err) break } } @@ -268,3 +268,12 @@ func RetryStreamingServerStream[Req, Resp any]( } } + +// useDebugErrorLevel indicates whether the specified error should be reported as a debug +// level log. +func logLevelForError(err error) log.Level { + if err != nil && strings.Contains(err.Error(), "connect: connection refused") { + return log.Debug + } + return log.Warn +}