Skip to content

Commit

Permalink
fix: retryable streaming server errors to be logged as debug (#2019)
Browse files Browse the repository at this point in the history
fixes #2002

unexpected warnings caused by retryable errors - retryable errors will
continue to be reported as debug.
  • Loading branch information
jonathanj-square authored Jul 10, 2024
1 parent 7354e2d commit 96890a3
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion internal/rpc/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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
}

0 comments on commit 96890a3

Please sign in to comment.