Problem
logger.ts writes all events to a daily-rotated file debug-YYYY-MM-DD.ndjson, but there is no size cap within a single day and no retention policy for old days. Two concrete problems:
- Unbounded daily file size — during a high-volume day (reconnect storms, development sessions), a single day's log file can grow to hundreds of MB or more. There is no rotation once it gets large.
- No retention — once the date rolls over, the previous day's file is left on disk untouched forever. Over a year of daily use, the user accumulates 365+ ndjson files under
app.getPath('logs'), silently consuming disk.
Location
File: packages/desktop/src/main/debug/logger.ts:95-98
function currentFilePath(): string {
const day = new Date().toISOString().slice(0, 10);
return join(options.debugDir, `debug-${day}.ndjson`);
}
Fix Approach
Add two bounds:
- Size-based rotation within a day: track the current file size; when it exceeds a threshold (e.g. 50 MB), rotate to
debug-YYYY-MM-DD.1.ndjson, .2.ndjson, etc.
- Age-based cleanup: on logger init, scan
options.debugDir for files matching debug-*.ndjson, parse the date from the filename, and delete files older than N days (e.g. 14 days). Keep it simple — no need for a full retention library.
Both should be configurable via CreateDebugLoggerOptions so tests can disable them.
Verification
- Run
pnpm check — must pass.
- Unit test for the filename parser + age filter logic.
- Manual: set a low rotation threshold (e.g. 10 KB), write enough events to trigger rotation, confirm a new file is created.
Context
- WG: Observability & DX
- Priority: Low (disk hygiene)
- Estimated effort: 1-2 hours
Problem
logger.tswrites all events to a daily-rotated filedebug-YYYY-MM-DD.ndjson, but there is no size cap within a single day and no retention policy for old days. Two concrete problems:app.getPath('logs'), silently consuming disk.Location
File:
packages/desktop/src/main/debug/logger.ts:95-98Fix Approach
Add two bounds:
debug-YYYY-MM-DD.1.ndjson,.2.ndjson, etc.options.debugDirfor files matchingdebug-*.ndjson, parse the date from the filename, and delete files older than N days (e.g. 14 days). Keep it simple — no need for a full retention library.Both should be configurable via
CreateDebugLoggerOptionsso tests can disable them.Verification
pnpm check— must pass.Context