fix(webui): stop the capture live-event notification duplicating payloads into the unbounded events table
Adversarial review of the just-shipped event inspector (a8f9f1b) found that
handleCapture's s.emit() call embedded the full (up to CaptureMaxBodyBytes,
default 256KiB) redacted body and headers into the events table's Data
column on every capture. That table has no retention or row-count prune
anywhere in the codebase -- unlike captured_events, whose three disk-bound
mechanics (size cap, rate limit, prune-on-write) this feature exists to
provide. An unauthenticated, rate-limited-only sender could grow the events
table without bound even though captured_events itself stayed correctly
capped, silently defeating docs/prds/event-capture-storage.md's stated
"max_events * max_body_bytes" worst-case guarantee.
Fix: the live "capture" SSE event now carries only {id, source} -- enough
for the dashboard to know something arrived -- and the event inspector
treats it purely as an invalidation signal, refetching GET /api/captures
for the authoritative row data instead of merging partial event fields into
its local list. This also fixes two smaller issues the same review found:
the previous approach's frontend dedup-by-id logic depended on a field
(Data["id"]) no test actually asserted, and received_at differed in
precision between the live-pushed and REST-listed copies of the same row --
both are moot now that the frontend has one source of truth for row data.
This commit is contained in:
1 parent
a8f9f1b339
commit
b07cb7c312
4 files changed
+42
-35
No files matched your search
@@ -12,7 +12,10 @@ import { captureRow } from "./capture-row.js";
|
||||
* Live updates ride the same /events SSE stream every other page uses
|
||||
* (Server.emit publishes a "capture" kind event on every successful
|
||||
* capture) rather than polling, so a captured event appears here without a
|
||||
* manual refresh.
|
||||
* manual refresh. That event is deliberately lightweight (id + source only,
|
||||
* no payload -- see handleCapture's comment on why): it is treated purely
|
||||
* as an invalidation signal, triggering a refetch of the authoritative list
|
||||
* rather than being merged into local state directly.
|
||||
*/
|
||||
export function capturesPage() {
|
||||
const root = el("div");
|
||||
@@ -29,9 +32,8 @@ export function capturesPage() {
|
||||
|
||||
const unsubscribe = subscribeEvents(
|
||||
(event) => {
|
||||
if (event.kind !== "capture" || event.data?.id == null) return;
|
||||
captures = [event.data, ...captures.filter((c) => c.id !== event.data.id)].slice(0, 200);
|
||||
renderRows();
|
||||
if (event.kind !== "capture") return;
|
||||
load();
|
||||
},
|
||||
(state) => {
|
||||
streamState.className = `pill pill-${state === "live" ? "ok" : "warn"}`;
|
||||
|
||||
Reference in new issue
Block a user