internal/server/http.go sets WriteTimeout = 10s on the http.Server, while internal/server/routes.go applies middleware.Timeout(60s) (requestTimeout). The 10s socket write deadline always fires first, so the 60s middleware timeout can never take effect and any response taking longer than 10s is cut off at the transport layer.
Definition of done:
the two timeouts are made consistent — either raise WriteTimeout to at least the middleware timeout, or lower the middleware timeout to match WriteTimeout — with a code comment explaining the chosen maximum request duration
the intended maximum request duration is documented in one place
no regression in existing server/middleware tests
Part of the road to 1.0 (see #33).
`internal/server/http.go` sets `WriteTimeout = 10s` on the `http.Server`, while `internal/server/routes.go` applies `middleware.Timeout(60s)` (`requestTimeout`). The 10s socket write deadline always fires first, so the 60s middleware timeout can never take effect and any response taking longer than 10s is cut off at the transport layer.
Definition of done:
- the two timeouts are made consistent — either raise `WriteTimeout` to at least the middleware timeout, or lower the middleware timeout to match `WriteTimeout` — with a code comment explaining the chosen maximum request duration
- the intended maximum request duration is documented in one place
- no regression in existing server/middleware tests
clawbot
added this to the 1.0.0 milestone 2026-08-07 13:10:59 +02:00
Confine this change to internal/server/http.go ONLY. Do NOT edit internal/server/routes.go — another change is in flight there, and requestTimeout (60s) stays the source of truth for the request budget.
The problem: http.go sets httpWriteTimeout = 10s, while the router applies middleware.Timeout(60s). The 10s socket write deadline fires first, so a slow response is cut at the transport layer before the 60s middleware timeout can return a clean 503.
Fix:
raise httpWriteTimeout to comfortably exceed the 60s request timeout — use 65 * time.Second — so the middleware timeout becomes the effective limit and returns a proper 503, instead of the transport killing the connection
leave httpReadTimeout (10s) unchanged
add a code comment on httpWriteTimeout noting it must stay above the router's requestTimeout (60s) so the middleware timeout wins
Definition of done:
httpWriteTimeout is greater than the 60s request middleware timeout, with a comment explaining the relationship
only internal/server/http.go is changed
existing server tests still pass
Gates and process:
make fmt before committing
host Go is 1.25 but go.mod needs 1.26, so validate with docker build . (must exit 0; runs fmt-check, lint, test, build)
branch from main named issue-62-write-timeout; commit subject ends with (closes #62)
open a PR (base main) and comment on it with the diff summary and the docker build . result
no AI-assistant/tooling references anywhere
## Implementation instructions
Confine this change to `internal/server/http.go` ONLY. Do NOT edit `internal/server/routes.go` — another change is in flight there, and `requestTimeout` (60s) stays the source of truth for the request budget.
The problem: `http.go` sets `httpWriteTimeout = 10s`, while the router applies `middleware.Timeout(60s)`. The 10s socket write deadline fires first, so a slow response is cut at the transport layer before the 60s middleware timeout can return a clean 503.
Fix:
- raise `httpWriteTimeout` to comfortably exceed the 60s request timeout — use `65 * time.Second` — so the middleware timeout becomes the effective limit and returns a proper 503, instead of the transport killing the connection
- leave `httpReadTimeout` (10s) unchanged
- add a code comment on `httpWriteTimeout` noting it must stay above the router's `requestTimeout` (60s) so the middleware timeout wins
Definition of done:
- `httpWriteTimeout` is greater than the 60s request middleware timeout, with a comment explaining the relationship
- only `internal/server/http.go` is changed
- existing server tests still pass
Gates and process:
- `make fmt` before committing
- host Go is 1.25 but `go.mod` needs 1.26, so validate with `docker build .` (must exit 0; runs fmt-check, lint, test, build)
- branch from `main` named `issue-62-write-timeout`; commit subject ends with ` (closes #62)`
- open a PR (base `main`) and comment on it with the diff summary and the `docker build .` result
- no AI-assistant/tooling references anywhere
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Part of the road to 1.0 (see #33).
internal/server/http.gosetsWriteTimeout = 10son thehttp.Server, whileinternal/server/routes.goappliesmiddleware.Timeout(60s)(requestTimeout). The 10s socket write deadline always fires first, so the 60s middleware timeout can never take effect and any response taking longer than 10s is cut off at the transport layer.Definition of done:
WriteTimeoutto at least the middleware timeout, or lower the middleware timeout to matchWriteTimeout— with a code comment explaining the chosen maximum request durationImplementation instructions
Confine this change to
internal/server/http.goONLY. Do NOT editinternal/server/routes.go— another change is in flight there, andrequestTimeout(60s) stays the source of truth for the request budget.The problem:
http.gosetshttpWriteTimeout = 10s, while the router appliesmiddleware.Timeout(60s). The 10s socket write deadline fires first, so a slow response is cut at the transport layer before the 60s middleware timeout can return a clean 503.Fix:
httpWriteTimeoutto comfortably exceed the 60s request timeout — use65 * time.Second— so the middleware timeout becomes the effective limit and returns a proper 503, instead of the transport killing the connectionhttpReadTimeout(10s) unchangedhttpWriteTimeoutnoting it must stay above the router'srequestTimeout(60s) so the middleware timeout winsDefinition of done:
httpWriteTimeoutis greater than the 60s request middleware timeout, with a comment explaining the relationshipinternal/server/http.gois changedGates and process:
make fmtbefore committinggo.modneeds 1.26, so validate withdocker build .(must exit 0; runs fmt-check, lint, test, build)mainnamedissue-62-write-timeout; commit subject ends with(closes #62)main) and comment on it with the diff summary and thedocker build .result