v1.1 plan: state the ReverseProxy abort behaviour the fix depends on; note the second stop

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
2026-09-25 08:41:30 -07:00
co-authored by Claude Fable 5.1
parent 74b8af4ce0
commit d8f6d2a804
2 changed files with 16 additions and 1 deletions
+8 -1
View File
@@ -33,7 +33,14 @@
2. **`/_crossbar/usage` JSON** encodes an empty result as `[]`: initialise the slice
(`rows := []store.UsageRow{}` / `make(..., 0)`) before encoding, on every `by` value and with
or without `since`. The text form prints its header line even with no rows.
3. Nothing else changes. Existing tests must keep passing; the two new ones must pass.
3. **Environment fact you need:** when the client disconnects while `httputil.ReverseProxy` is
copying the response and the request came through a real `http.Server`, `ServeHTTP` does not
return — it panics with `http.ErrAbortHandler`, which the server swallows. Code after
`rp.ServeHTTP` never runs on that path. Write the accounting row from a **deferred** function
in `forward`: `recover()`, record (status 499 when the recovered value is `http.ErrAbortHandler`
or the request context is done), then re-panic with the same value so the server keeps its
semantics. Exactly one row per request on every path.
4. Nothing else changes. Existing tests must keep passing; the two new ones must pass.
## Steps