fix(server): shut down through fx so buffered reports flush (closes #22)
check / check (push) Successful in 1m11s
check / check (push) Successful in 1m11s
The server ran os.Exit at the end of its own goroutine, racing fx's teardown and sometimes killing the process before reportbuf's OnStop flushed — silently losing a full flush window of telemetry on every restart, at exit 0. Shutdown now goes through fx.Shutdowner, so every OnStop runs in order. The http.Server is built synchronously in OnStart before the serving goroutine, so shutdown can no longer race or nil-deref it. A listen failure exits non-zero via fx.ExitCode(1). reportbuf's OnStop is guarded by sync.Once. writeTimeout now exceeds the chi per-request budget so that budget is reachable. Dead startupTime, exitCode, and cancelFunc fields are gone. A new test asserts a buffered report reaches disk after the lifecycle stops. Model: opus-4-8
This commit was merged in pull request #57.
This commit is contained in:
@@ -22,6 +22,15 @@ files, so merging it also closes most compliance gaps.
|
||||
|
||||
# Completed Steps
|
||||
|
||||
- 2026-09-21: shutdown lifecycle correctness. The process now shuts down through
|
||||
fx instead of `os.Exit`, so every component's `OnStop` runs and buffered
|
||||
reports are flushed to disk on `SIGTERM` — previously a full flush window of
|
||||
telemetry was silently lost on every restart. The `http.Server` is now built
|
||||
before its serving goroutine starts, so shutdown can no longer race or
|
||||
nil-deref it; a listen failure exits non-zero via `fx.Shutdowner`; `reportbuf`
|
||||
`OnStop` is idempotent; and `writeTimeout` now exceeds the chi per-request
|
||||
budget so that budget is actually reachable. Dead `startupTime`, `exitCode`,
|
||||
and `cancelFunc` fields were removed
|
||||
- 2026-09-21: backend HTTP hardening (issue #19): added `ReadHeaderTimeout` and
|
||||
`IdleTimeout` to the server, a `SecurityHeaders` middleware (HSTS, tight CSP,
|
||||
frame/sniff/referrer/permissions headers) registered before CORS, and
|
||||
|
||||
Reference in New Issue
Block a user