From 4f7165530c5a547c2408bd48d75f3cdf467c61d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20=22Pisco=22=20Fernandes?= Date: Tue, 5 Mar 2024 15:07:59 +0000 Subject: [PATCH] TUN-8275: Skip write timeout log on "no network activity" ## 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. --- quic/safe_stream.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/quic/safe_stream.go b/quic/safe_stream.go index 1351a0c3..db347aac 100644 --- a/quic/safe_stream.go +++ b/quic/safe_stream.go @@ -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 @@ -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) } }