Description
Example program with issue: https://go.dev/play/p/DoZD1wMDPhw
Most time I find myself wanting to run my http requests with tight deadlines using http.Server.WriteTimeout
.
While at the same time, I would like requests to the pprof endpoints to operate under more lenient timeouts.
For example I would set http.Server.WriteTimeout
to 3 seconds and at the same time want to be able to take a pprof sample that would take a long time curl -vkL "http://localhost:9192/debug/pprof/profile?seconds=30"
I thought I would use http.NewResponseController
to do that, see https://go.dev/play/p/DoZD1wMDPhw
However, that fails with profile duration exceeds server's WriteTimeout
.
This is because the pprof handlers only consider the server timeout;
go/src/net/http/pprof/pprof.go
Lines 117 to 120 in a9d4b2d
My proposal is that they should also consider any timeout that has been set by http.ResponseController
.
I don't know how such a functionality might be implemented since durationExceedsWriteTimeout
takes a http.Request
and its context does not contain information on whether http.ResponseController has been used.
The current workaround is to use two servers, one for application handler and one for pprof handlers each with its own http.Server.WriteTimeout
. But I like having one server.