[Bug] debug logger has no size rotation or retention policy
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.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 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
Hi @samzong, Thanks for opening an issue! We will look into it as soon as possible.
Details
Instructions for interacting with me using comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the gh-ci-bot repository.
The debug log's unbounded daily file size and lack of retention will silently consume disk. I'd handle this by adding configurable size rotation and age-based cleanup directly in logger.ts. I can have a PR with tests up in a few hours—I've implemented similar file rotation in production Node.js apps.
The unbounded daily file size and missing retention policy are clear issues. I'd handle this by adding configurable size rotation and age-based cleanup directly in logger.ts, as outlined. Can have a PR up in a few hours—I've implemented similar file-based logging with rotation in production TypeScript apps.