Skip to content

Commit 6ee9b23

Browse files
aledbfroboquat
authored andcommitted
[supervisor] Remove common warnings
1 parent 7f9eada commit 6ee9b23

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

components/supervisor/pkg/ports/ports.go

+24-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"reflect"
1717
"sort"
1818
"sync"
19+
"syscall"
1920
"time"
2021

2122
"golang.org/x/net/nettest"
@@ -760,8 +761,30 @@ func startLocalhostProxy(port uint32) (io.Closer, error) {
760761
originalDirector(req)
761762
}
762763
proxy.ErrorHandler = func(rw http.ResponseWriter, req *http.Request, err error) {
763-
log.WithError(err).WithField("local-port", port).WithField("url", req.URL.String()).Warn("localhost proxy request failed")
764764
rw.WriteHeader(http.StatusBadGateway)
765+
766+
// avoid common warnings
767+
768+
if errors.Is(err, context.Canceled) {
769+
return
770+
}
771+
772+
if errors.Is(err, io.EOF) {
773+
return
774+
}
775+
776+
if errors.Is(err, syscall.ECONNREFUSED) {
777+
return
778+
}
779+
780+
var netOpErr *net.OpError
781+
if errors.As(err, &netOpErr) {
782+
if netOpErr.Op == "read" {
783+
return
784+
}
785+
}
786+
787+
log.WithError(err).WithField("local-port", port).WithField("url", req.URL.String()).Warn("localhost proxy request failed")
765788
}
766789

767790
proxyAddr := fmt.Sprintf("%v:%d", workspaceIPAdress, port)

0 commit comments

Comments
 (0)