From d97d4e483ce2806ff988630cd68ebe46583d5771 Mon Sep 17 00:00:00 2001 From: Tony Date: Wed, 21 Aug 2024 14:48:52 +0300 Subject: [PATCH] fix: producing timeout error in case with no timeout errors (#180) Co-authored-by: Anton Piunov --- proxy/server.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/proxy/server.go b/proxy/server.go index 233839a..0c3bb09 100644 --- a/proxy/server.go +++ b/proxy/server.go @@ -22,8 +22,9 @@ func ReadBytes(conn *net.TCPConn, dest []byte) ([]byte, error) { func readBytesInternal(conn *net.TCPConn, dest []byte) (int, error) { totalRead, err := conn.Read(dest) if err != nil { - switch err.(type) { - case *net.OpError: + var opError *net.OpError + switch { + case errors.As(err, &opError) && opError.Timeout(): return totalRead, errors.New("timed out") default: return totalRead, err