You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(serve): make the API write timeout configurable (kenn-io#1148)
## What
Adds a `--write-timeout` duration flag to `serve` and `pg serve`, making the API
write deadline configurable. The default is unchanged at 30s. A non-positive value
disables the deadline.
## Why
The write deadline was hardcoded at 30s. On large shared datasets the full-history
analytics aggregates (heatmap, activity, usage summary) can exceed it and return
`503` with `{"error":"request timed out"}`, which surfaces as blank "request timed
out" dashboard panels. Operators had no way to raise it. Relates to kenn-io#1147.
## Where to look
- `internal/config/config.go` — the flag is registered on both the `flag` and
`pflag` serve flag sets (so `serve` and `pg serve` both accept it) and mapped to
`Config.WriteTimeout` in `applyFlagValue`, mirroring `events-coalesce-interval`.
- `internal/server/middleware.go` — the standard-handler timeout wrapper now
bypasses `http.TimeoutHandler` when the timeout is non-positive, so `0` disables
the deadline instead of firing immediately. The typed (Huma) API path already
had this guard; this brings the two paths into agreement.
- `docs/remote-access.md` — documents raising the timeout for slow aggregates and
the flag reference row.
## Tradeoffs and limitations
- Raising the timeout treats the symptom. When aggregates are slow enough to need a
large value, the underlying database-side cost is usually the real fix — for a
multi-tenant read role, a set-based row-level-security predicate rather than a
per-row function call. The docs note points there; #1 has the detail.
- Flag only; no new config-file or environment key was added, consistent with the
neighboring serve duration flags.
Co-authored-by: TechnoPhobe01 <Technophobe01@users.noreply.github.com>
0 commit comments