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.
This commit is contained in:
parent
a36fa07aba
commit
4f7165530c
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue