MCPcopy Index your code
hub / github.com/cloudflare/cloudflared / handleWriteError

Method handleWriteError

quic/safe_stream.go:56–72  ·  view source on GitHub ↗

Handles the timeout error in case it happened, by canceling the stream write.

(err error)

Source from the content-addressed store, hash-verified

54
55// Handles the timeout error in case it happened, by canceling the stream write.
56func (s *SafeStreamCloser) handleWriteError(err error) {
57 // If we are closing the stream we just ignore any write error.
58 if s.closing.Load() {
59 return
60 }
61 var netErr net.Error
62 if errors.As(err, &netErr) {
63 if netErr.Timeout() {
64 // We don't need to log if what cause the timeout was no network activity.
65 if !errors.Is(netErr, &idleTimeoutError) {
66 s.log.Error().Err(netErr).Msg("Closing quic stream due to timeout while writing")
67 }
68 // We need to explicitly cancel the write so that it frees all buffers.
69 s.stream.CancelWrite(0)
70 }
71 }
72}
73
74func (s *SafeStreamCloser) Close() error {
75 // Set this stream to a closing state.

Callers 1

WriteMethod · 0.95

Calls 3

IsMethod · 0.80
ErrMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected