Skip to content

fix: drop previous .old before logger rotation rename (Windows-safe) - #555

Merged
ranxianglei merged 1 commit into
masterfrom
2026-09-05_logger-rotate-old-unlink
Sep 5, 2026
Merged

ranxianglei merged 1 commit into
masterfrom
2026-09-05_logger-rotate-old-unlink

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Split out of PR#277 per maintainer decision: only the one production-impacting fix from #276 is kept; the debug-dump GC and launcher tmplog sweep are dropped (debug-only concern / tmpdir hygiene).

Problem (#276, item ③): openStream rotates bili.log → bili.log.old with renameSync without removing an existing .old first. On POSIX rename overwrites, so rotation works and at most one generation survives. On Windows renameSync cannot overwrite an existing target — it throws, the surrounding catch swallows it, and rotation silently never happens: bili.log grows unbounded for the life of the install.

Fix: try { unlinkSync(file + ".old") } catch {} immediately before the rename. Windows-safe (target can't pre-exist), and on POSIX it makes the ≤1-generation guarantee explicit instead of relying on overwrite semantics.

Test: tests/logger-rotate.test.ts — writes two generations past MAX_BYTES through the real logger and asserts exactly one .old exists and the fresh log is post-rotation.

Pre-flight: typecheck ✓ · logger tests 18/18 ✓ · build ✓.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-09-05_logger-rotate-old-unlink (7c690b8)

Option A — Install from npm PR tag (recommended)

npm install -g billion-context@pr-555

Each push to this PR publishes a new version under the pr-555 npm tag.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr555.tgz
npm install -g package

This comment is automatically updated on each push.

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