Skip to content

Commit

Permalink
TUN-8275: Skip write timeout log on "no network activity"
Browse files Browse the repository at this point in the history
## Summary
To avoid having to verbose logs we need to only log when an
actual issue occurred. Therefore, we will be skipping any error
logging if the write timeout is caused by no network activity
which just means that nothing is being sent through the stream.
  • Loading branch information
jcsf committed Mar 6, 2024
1 parent a36fa07 commit 4f71655
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion quic/safe_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import (
"github.com/rs/zerolog/log"
)

// The error that is throw by the writer when there is `no network activity`.
var idleTimeoutError = quic.IdleTimeoutError{}

type SafeStreamCloser struct {
lock sync.Mutex
stream quic.Stream
Expand Down Expand Up @@ -52,7 +55,10 @@ func (s *SafeStreamCloser) handleTimeout(err error) {
var netErr net.Error
if errors.As(err, &netErr) {
if netErr.Timeout() {
s.log.Error().Err(netErr).Msg("Closing quic stream due to timeout while writing")
// We don't need to log if what cause the timeout was `no network activity`.
if !errors.Is(netErr, &idleTimeoutError) {
s.log.Error().Err(netErr).Msg("Closing quic stream due to timeout while writing")
}
s.stream.CancelWrite(0)
}
}
Expand Down

0 comments on commit 4f71655

Please sign in to comment.