Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: retryable streaming server errors to be logged as debug #2019

Merged
merged 3 commits into from
Jul 10, 2024

Conversation

jonathanj-square
Copy link
Contributor

fixes #2002

unexpected warnings caused by retryable errors - retryable errors will continue to be reported as debug.

@jonathanj-square jonathanj-square requested review from alecthomas and a team as code owners July 9, 2024 18:17
@jonathanj-square jonathanj-square requested review from deniseli and removed request for a team July 9, 2024 18:17
@ftl-robot ftl-robot mentioned this pull request Jul 9, 2024
unexpected warnings caused by retryable errors - retryable errors will continue to be reported as debug.
@@ -240,7 +240,9 @@ func RetryStreamingServerStream[Req, Resp any](
} else {
// Stream terminated; check if this was caused by an error
err = stream.Err()
logLevel = log.Warn
if !useDebugErrorLevel(err) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For readability, could we refactor this to logLevel = logLevelForError(err)? That way, you don't need to mentally parse the ! and the variable scope/flow.

@jonathanj-square jonathanj-square merged commit 96890a3 into main Jul 10, 2024
49 checks passed
@jonathanj-square jonathanj-square deleted the jonathanj/issue_2002 branch July 10, 2024 17:42
@@ -268,3 +268,12 @@ func RetryStreamingServerStream[Req, Resp any](

}
}

// useDebugErrorLevel indicates whether the specified error should be reported as a debug
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: would you mind making a quick followup PR to fix this comment? Thanks! :)

// 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") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to use errors.Is for this check, like: https://go.dev/play/p/M0X4W1wcSQn

Sorry I missed this earlier!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ftl build warns repeatedly about connection refused
2 participants