Skip to content

Commit

Permalink
unset http WriteTimeout when -pprof
Browse files Browse the repository at this point in the history
  • Loading branch information
sentriz committed Dec 2, 2023
1 parent f98b232 commit 5b5572d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion cmd/gonic/gonic.go
Expand Up @@ -285,7 +285,17 @@ func main() {
}))
}

var (
readTimeout = 5 * time.Second
writeTimeout = 5 * time.Second
idleTimeout = 5 * time.Second
)

if *confPprof {
// overwrite global WriteTimeout. in future we should set this only for these handlers
// https://github.com/golang/go/issues/62358
writeTimeout = 0

mux.HandleFunc("/debug/pprof/", pprof.Index)
mux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
mux.HandleFunc("/debug/pprof/profile", pprof.Profile)
Expand All @@ -300,7 +310,7 @@ func main() {

server := &http.Server{
Addr: *confListenAddr,
ReadTimeout: 5 * time.Second, WriteTimeout: 5 * time.Second, IdleTimeout: 5 * time.Second,
ReadTimeout: readTimeout, WriteTimeout: writeTimeout, IdleTimeout: idleTimeout,
Handler: mux,
}
errgrp.Go(func() error {
Expand Down

0 comments on commit 5b5572d

Please sign in to comment.