Skip to content

fix(file): preserve records buffered before rotation - #2653

Draft
Huzaifa-Asif wants to merge 1 commit into
winstonjs:masterfrom
Huzaifa-Asif:fix/flush-opening-file-before-rotation
Draft

Huzaifa-Asif wants to merge 1 commit into
winstonjs:masterfrom
Huzaifa-Asif:fix/flush-opening-file-before-rotation

Conversation

@Huzaifa-Asif

Copy link
Copy Markdown

Fixes #2354.

When records buffered before the first file opens exceed maxsize, the opening-rotation path destroys the destination before its writes finish. This can discard the entire initial batch. Wait for that destination to finish before cleanup, compression or renaming, and opening the next file. A write error also releases the wait and advances rotation, preserving the existing error-reporting behavior; bytes from a failed write are not recoverable.

Add real-file logger regressions for ordinary, tailable and compressed rotation, ending before the first open, and accepting later records after an injected native write failure. The compressed cases also check that archiving starts after the source destination finishes. Restore existing assertions that documented lost initial records, and make the steady-state size test wait for opening and each logged record.

maxsize remains a best-effort rotation threshold: a batch buffered before opening, or a single oversized record, can exceed it.

Validation on macOS arm64, Node 24.18.1:

  • Full unit suite: 240 passed, 3 existing todos; coverage thresholds passed. The file transport suite has 25 passing tests and 2 of those todos.
  • Unit tests used --watchman=false --runInBand --forceExit; existing open handles leave ordinary Jest running after assertions finish.
  • Integration suite: 3 passed.
  • Lint: no errors, 10 existing warnings. Babel build, TypeScript 6.0.3 fixtures, and git diff --check passed.

AI assistance: Codex implemented and tested this patch, and a separate Codex reviewer investigated it independently. No personal human review is claimed.

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.

[Bug]: File transport stops writing to file when log entry is greater than maxsize

1 participant