Skip to content

fix(view): /view/<run-id> budgets the page it renders and states the drop - #105

Merged
lroolle merged 1 commit into
mainfrom
fix/view-budget
Sep 2, 2026
Merged

fix(view): /view/<run-id> budgets the page it renders and states the drop#105
lroolle merged 1 commit into
mainfrom
fix/view-budget

Conversation

@lroolle

@lroolle lroolle commented Sep 1, 2026

Copy link
Copy Markdown
Member

Item 3 of Eric's 2026-08-31 batch: http://127.0.0.1:9317/view/9431ef5f-… (a very long work session) would not open.

Diagnosis (measured on that exact run)

The server never failed — it succeeded at the wrong thing. /view/<run-id> read the trace with the streaming reader's budget (TAIL_BYTES = 256 MB) and inlined every kept byte ~1:1 into one HTML document:

  • the run's trace: 4.14 MB on disk (.zst), 708 MB decoded, 4115 lines
  • the route produced a 257 MB HTML response (95 pairs at ~2.7 MB each) at 4.2 GB server RSS — the browser tab dies parsing a 257 MB inline script
  • and 78% of the session was silently dropped with no indication anywhere (the CLI prints truncationNotice; the route discarded result.truncated)

Fix

  • VIEW_BYTES (32 MB) — a document budget, distinct from the streaming budget — applied at the route; the same run now serves a 33 MB page in ~5 s (verified against the real trace)
  • gzip when the client accepts it (~18 MB on the wire; the trace compresses 163x)
  • ?full=1 / ?bytes=N (MB) escape hatches, mirroring the CLI's --full
  • the page states the drop: PageMeta.truncated renders an amber newest X MB of Y MB header chip (tip: dropped lines, unscanned older files); on /view/<run-id> the chip links ?full=1. cctrace view serve and --html pages carry the same chip — the terminal already said it, but a reader who got the URL never saw the terminal

Not in this PR (follow-ups, ranked in the diagnosis)

Compact-on-render (stub superseded request bodies at render time — the only fix that keeps a whole 438-pair session visible in ~20-50 MB) and streaming NDJSON hydration (kills the giant string on both ends, incl. the one-frame WS init). Filed as an issue.

Verification

bun test 888/0 (new: a 3 MB fixture through ?bytes=1 keeps the newest pair, drops the oldest, stamps truncated; ?full=1 restores everything and stamps nothing; the chip renders from meta and stays empty without it). Real-world: the exact failing run served through the new route — status 200, 33 MB decoded, 18 MB wire, truncation chip present.

🤖 Generated with Claude Code

…drop

The route read with the streaming reader's 256 MB budget and inlined
every kept byte into one document: a 708 MB session produced a 257 MB
page no tab survives, silently missing 78% of the session. VIEW_BYTES
(32 MB) now budgets the render, the response gzips, ?full=1 / ?bytes=N
are the escape hatches, and every budgeted page (this route, view
serve, --html) carries an amber truncation chip naming what was kept.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@lroolle
lroolle merged commit adc5f83 into main Sep 2, 2026
1 check passed
@lroolle
lroolle deleted the fix/view-budget branch September 2, 2026 04:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant