Skip to content

Commit 1501cae

Browse files
committed
chore(node): add http timeout defaults
1 parent dbcc7ec commit 1501cae

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

node/http.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ import (
2626
"google.golang.org/grpc"
2727
)
2828

29+
const (
30+
defaultReadTimeout = 30 * time.Second
31+
defaultReadHeaderTimeout = 30 * time.Second
32+
defaultWriteTimeout = 30 * time.Second
33+
defaultIdleTimeout = 2 * time.Minute
34+
)
35+
2936
type httpService struct {
3037
srv *http.Server
3138
}
@@ -62,7 +69,10 @@ func makeHTTPService(host string, port uint16, handler http.Handler) *httpServic
6269
srv: &http.Server{
6370
Addr: net.JoinHostPort(host, portStr),
6471
Handler: handler,
65-
ReadHeaderTimeout: 30 * time.Second,
72+
ReadHeaderTimeout: defaultReadHeaderTimeout,
73+
ReadTimeout: defaultReadTimeout,
74+
WriteTimeout: defaultWriteTimeout,
75+
IdleTimeout: defaultIdleTimeout,
6676
},
6777
}
6878
}

0 commit comments

Comments
 (0)