From 0c9c885d51a4e78f2fee0d47d89be245cd02d9b8 Mon Sep 17 00:00:00 2001 From: clawbot Date: Fri, 7 Aug 2026 13:58:28 +0200 Subject: [PATCH] Raise HTTP WriteTimeout above the request middleware timeout (closes #62) (#72) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Raise `httpWriteTimeout` in `internal/server/http.go` from 10s to `65 * time.Second` so it comfortably exceeds the router's 60s `requestTimeout`. This makes the `middleware.Timeout(60s)` the effective request limit — a slow response now returns a clean 503 from the middleware instead of being cut at the socket write deadline by the transport. `httpReadTimeout` stays at 10s. A comment on `httpWriteTimeout` documents that it must remain above the 60s request timeout. Change is confined to `internal/server/http.go`; `routes.go` is untouched. Closes #62 Co-authored-by: sneak Reviewed-on: https://git.eeqj.de/sneak/webhooker/pulls/72 Co-authored-by: clawbot Co-committed-by: clawbot --- internal/server/http.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/server/http.go b/internal/server/http.go index efb7705..4c99ba5 100644 --- a/internal/server/http.go +++ b/internal/server/http.go @@ -13,8 +13,11 @@ const ( httpReadTimeout = 10 * time.Second // httpWriteTimeout is the maximum duration before timing out - // writes of the response. - httpWriteTimeout = 10 * time.Second + // writes of the response. It must stay above the router's + // requestTimeout (60s, in routes.go) so the middleware timeout + // fires first and returns a clean 503, rather than the transport + // cutting the connection at the socket write deadline. + httpWriteTimeout = 65 * time.Second // httpMaxHeaderBytes is the maximum number of bytes the // server will read parsing the request headers.