Repository navigation
Stop service logs growing without limit - #5933
Merged
Merged
Conversation
pino-roll's limit.count only deleted files created by the current process, so every restart left the previous run's rotated logs behind (88 server.N.log files on one Mac). Enable removeOtherLogFiles so each component keeps its five newest rotated files. The launcher's append-only server-stdio.log and host-daemon-stdio.log had no cap at all. When one is over 10 MB as its service starts, rename it to <name>-stdio.1.log, replacing the previous copy. The child still writes directly to the file, preserving the backpressure protection. Refs #5821 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The logger echoed every line to stdout through pino-pretty. Under the bb-app launcher stdout is server-stdio.log or host-daemon-stdio.log, so those files were an unrotated duplicate of the rotating application logs and grew with all logging (562 MB on one Mac). Skip the pretty stream when stdout is a plain file. Terminals and pipes keep it, including turbo-run pnpm dev and the desktop app. The capture files now hold startup errors, crashes, and other output that bypasses the logger. The tarball smoke now waits for the host plugin worker in host-daemon.N.log, and the docs point to the rotating logs. Refs #5821 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
pino-roll's removeOtherLogFiles keeps the highest-numbered files, but pino-roll restarts numbering at 1 when a process starts on a day with no log files born yet. After an overnight restart it deleted the new active log and every later roll, keeping the previous day's files. Prune <component>.N.log files when the logger starts instead, keeping the five most recently written regardless of their numbers. pino-roll's own per-process limit still bounds a long run. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
added a commit
that referenced
this pull request
Dec 1, 2026
## Human comments ## What was wrong #5933 (Oct 20) stopped the logger from copying every line into `server-stdio.log` / `host-daemon-stdio.log`. Since then those files only collect output that bypasses the logger, so they grow very slowly. On a busy server, the live `server-stdio.log` grew 34 KB in 40 days. The launcher only replaces `<name>-stdio.1.log` when the live file is over 10 MB at spawn, which now practically never happens. A large `.1.log` left by an earlier, noisier run therefore stays on disk indefinitely: 594 MB on my Mac (last written Oct 21) and 887 MB in the report. ## What changed - `packages/bb-app/src/logged-process.ts`: at every spawn, the launcher cuts `<name>-stdio.1.log` down to its last 10 MB, keeping the most recent output. This covers both a fresh rotation, where the run that just ended may have written far more than 10 MB, and an oversized file left by an earlier run. The live file still rotates at spawn as before. - Updated the stdio log description in `packages/bb-app/README.md`, `docs/debugging-and-qa.md` and the `bb guide machines` template. Departures from the issue's suggestions, based on measurements from a server that had been up 23 h: - **No runtime rotation.** Since #5933 the live capture grows by KBs per month (38 KB in total across 80 dev data dirs), so piping or watching the child's output costs more than it saves. - **`handlerStats` unchanged.** It holds one counter record per plugin and does not grow. It measures per-call latency, which is useful in its own right (for example, a 109 s worktree creation). It is not presented as CPU time. - **`inFlightWorkAtObservation` unchanged.** It stayed at 16–20 frames across 242 stall entries. Each stall entry already names the blocker in `stallCauseCandidate` / `longestSynchronousWork`; that blocker was a synchronous DB write in every entry I checked. ## How you verified - Two regression tests in `packages/bb-app/test/logged-process.test.ts`: - a 25 MB live capture is rotated, and the `.1.log` keeps exactly its last 10 MB, ending with the last line written; - an orphaned 600 MB `.1.log` is trimmed to 10 MB. - Both tests fail on the old code and pass with the fix. - `pnpm exec turbo run test typecheck --filter=bb-app` passes (233 tests). - Ran the fix against a copy of the real 594 MB orphan: it went from 594,062,408 bytes to 10,485,760, the final 200 bytes were unchanged, and the new run's output was appended to the live file. Fixes #8326 > AGENT GENERATED 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
scowalt
pushed a commit
to scowalt/bb
that referenced
this pull request
Dec 1, 2026
## Human comments ## What was wrong get-bb#5933 (Oct 20) stopped the logger from copying every line into `server-stdio.log` / `host-daemon-stdio.log`. Since then those files only collect output that bypasses the logger, so they grow very slowly. On a busy server, the live `server-stdio.log` grew 34 KB in 40 days. The launcher only replaces `<name>-stdio.1.log` when the live file is over 10 MB at spawn, which now practically never happens. A large `.1.log` left by an earlier, noisier run therefore stays on disk indefinitely: 594 MB on my Mac (last written Oct 21) and 887 MB in the report. ## What changed - `packages/bb-app/src/logged-process.ts`: at every spawn, the launcher cuts `<name>-stdio.1.log` down to its last 10 MB, keeping the most recent output. This covers both a fresh rotation, where the run that just ended may have written far more than 10 MB, and an oversized file left by an earlier run. The live file still rotates at spawn as before. - Updated the stdio log description in `packages/bb-app/README.md`, `docs/debugging-and-qa.md` and the `bb guide machines` template. Departures from the issue's suggestions, based on measurements from a server that had been up 23 h: - **No runtime rotation.** Since get-bb#5933 the live capture grows by KBs per month (38 KB in total across 80 dev data dirs), so piping or watching the child's output costs more than it saves. - **`handlerStats` unchanged.** It holds one counter record per plugin and does not grow. It measures per-call latency, which is useful in its own right (for example, a 109 s worktree creation). It is not presented as CPU time. - **`inFlightWorkAtObservation` unchanged.** It stayed at 16–20 frames across 242 stall entries. Each stall entry already names the blocker in `stallCauseCandidate` / `longestSynchronousWork`; that blocker was a synchronous DB write in every entry I checked. ## How you verified - Two regression tests in `packages/bb-app/test/logged-process.test.ts`: - a 25 MB live capture is rotated, and the `.1.log` keeps exactly its last 10 MB, ending with the last line written; - an orphaned 600 MB `.1.log` is trimmed to 10 MB. - Both tests fail on the old code and pass with the fix. - `pnpm exec turbo run test typecheck --filter=bb-app` passes (233 tests). - Ran the fix against a copy of the real 594 MB orphan: it went from 594,062,408 bytes to 10,485,760, the final 200 bytes were unchanged, and the new run's output was appended to the live file. Fixes get-bb#8326 > AGENT GENERATED 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
Two log caps were missing (#5821):
@bb/loggersends each line to the rotating<component>.N.logfile and, throughpino-pretty, to stdout. Since Prevent terminal backpressure from blocking service logs #3394 the launcher points service stdout directly at the append-onlyserver-stdio.log/host-daemon-stdio.log, so these files grew with all logging and never rotated (437 MB in the report, 562 MB on another Mac).limit.countonly deletes files created by the current process. Every restart left the previous run's files behind (88server.N.log+ 81host-daemon.N.log, 407 MB, on the same Mac withcount: 5). pino-roll'sremoveOtherLogFilesis not a safe fix: it keeps the highest-numbered files, but pino-roll restarts numbering at 1 when a process starts on a day with no log files born yet. After an overnight restart it would delete the new active log and every later roll.What changed
packages/logger: skip thepino-prettystdout target when stdout is a plain file, which is exactly the launcher's capture. Terminals and pipes keep it: turbo does not givepnpm devtasks a TTY, so anisTTYcheck would have blanked the dev console. The capture files now hold startup errors, crashes, and other output that bypasses the logger. Startup failures are written to stderr directly, so the installer's "seehost-daemon-stdio.log" hint still applies.packages/logger: when the logger starts, prune<component>.N.logfiles to the five most recently written, regardless of their numbers. Only exact<component>.<N>.lognames match, so stdio captures, crash reports, and other components are untouched. Only the server and host daemon callcreateLogger, one process each per data directory, so no live file is pruned. pino-roll's per-processlimit.countstill bounds a long run.packages/bb-app/src/logged-process.ts: when a capture file is over 10 MB as its service starts, rename it to<name>-stdio.1.log(replacing the previous one) before opening a fresh file. The child still writes directly to the file, so the Prevent terminal backpressure from blocking service logs #3394 backpressure protection is unchanged.smoke-tarball.mjsnow waits for "Host plugin worker ready" inhost-daemon.N.loginstead of the stdio capture.docs/debugging-and-qa.md, the machines guide template, the web guide's "I need bb's logs" answer, and thebb-serverhelp and startup line now point to the rotating logs.There are no server/daemon wire changes.
How you verified
@bb/logger: 8server.N.logfiles from earlier runs, where low numbers are newer than high ones, are pruned at startup to the 5 most recently written, andserver-stdio.log/ other components' logs are left alone. This test also fails against pino-roll'sremoveOtherLogFiles.@bb/logger: with stdout redirected to a file, nothing is echoed there and the line still lands in the rotating log.bb-app: an oversized capture file is moved to-stdio.1.logat spawn, and the new file starts fresh.pnpm exec turbo run test typecheck lint --filter='...[origin/main]': 188/189 tasks passed. The one failure,@bb/server"hot-reloads a source-layout builtin server", timed out under load and passes on its own. It does not read logs.pnpm exec turbo run smoke:tarball --filter=bb-apppassed, including the moved plugin-ready check.bb-appstack against a scratch data dir seeded with 7 backdatedserver.10x.logfiles and an 11 MBserver-stdio.log: the old logs were pruned to 5, today'sserver.1.logwas kept, the capture moved toserver-stdio.1.log, the newserver-stdio.logheld only Node's SQLite ExperimentalWarning (169 bytes), andhost-daemon-stdio.logwas empty.server.100–104.log, then start and roll): withremoveOtherLogFiles, the newserver.1.log/server.2.logwere deleted. With startup pruning, both survive.spawnLoggedProcess+createLoggerthrough 8 restarts grewserver-stdio.loglinearly to 99 MB and left 9 rotated files despitecount: 5.User-visible change:
tail -F ~/.bb/logs/*-stdio.logno longer shows routine activity. Usetail -F ~/.bb/logs/*.logor the desktop log viewer, which already reads the rotating files.Fixes #5821
🤖 Generated with Claude Code