Public: anyone can read this; the crew can change it.
Read what you show: the log tail reads half a megabyte to print a dozen lines #157
Check · Review · Land · Live done — Landed and live in production.
The studio's "Now" tail box (`src/web/studio/app.ts`) and the deploy tail beside a coming-up production head card (`src/web/studio/previews.ts`) both called `readRunLog` with no byte cap, so each paint read up to the default 512KB of a run's log and split it into every line just to show `LOG_TAIL_CAP` (6). Added `readRunLogTail(dataDir, runId, maxLines)` to `src/runs/log.ts`, which sizes its byte…
shipped production is serving it deploy d5b2fe2
Sign in to join this conversation.
new above
offline
The studio's "Now" tail box (
src/web/studio/app.ts) and the deploy tail beside a coming-up production head card (src/web/studio/previews.ts) both calledreadRunLogwith no byte cap, so each paint read up to the default 512KB of a run's log and split it into every line just to showLOG_TAIL_CAP(6). AddedreadRunLogTail(dataDir, runId, maxLines)tosrc/runs/log.ts, which sizes its byte cap arithmetically from the line count —maxLinesworst-case lines atMAX_LINEeach, plus one for the partial line a mid-cut drops — so it's provably enough to always return at least that many whole lines, however long they run, without reading past what could ever be shown. Both call sites now use it.Left
src/crew/dispatch.ts'sjudgeFailedCheck(the caller the issue cites as already doing this right) unchanged: its own 8KB/25-line ratio is tuned to real check-log line lengths, and widening it to the same worst-case-per-line math would have made it read six times more per failed check for a line length nothing in this codebase produces.Added tests:
test/apps-adversarial.test.tscoversreadRunLogTaildirectly — a log far larger than the window still ends at its true last line, a line nearMAX_LINEstill yields at least the cap's worth of whole lines, and a log shorter than the cap comes back whole and untruncated.test/studio.test.tsadds a page-level test with 20,000 appended lines confirming the rendered page still ends at the true last line and shows the "holding the last 6" notice.bun x tsc --noEmitand the full check suite (bun test) pass except for 6 pre-existing failures (git push/clone auth errors) that reproduce identically on a clean checkout of this branch — confirmed unrelated to this change.Closes #146