Bug
On Windows, bitsocial logs -f (follow mode) does not emit new lines that another process appends to the current log file. The CLI emits the initial dump and then sits silent, even after the file size visibly grows.
Linux and macOS behave correctly.
Repro / evidence
The test continues watching old file if no new file appears (test/cli/logs.test.ts:462) reliably fails on Windows in CI:
The assertion:
expected '[2026-05-01T00:00:00.000Z] initial li…' to contain 'APPENDED_LINE'
The test:
- Writes an initial line to a log file.
- Spawns
bitsocial logs -f against it.
- After observing the initial line on stdout, appends
APPENDED_LINE to the same file.
- Expects the CLI to emit
APPENDED_LINE within 8 seconds.
On Windows the CLI runs the full 8s without emitting the appended line. Linux and macOS pass.
Root cause
src/cli/commands/logs.ts uses fs.watchFile(currentLogFile, { interval: 300 }, readNewData) to detect new bytes. fs.watchFile is backed by libuv's uv_fs_poll_t. On Windows, this notification mechanism does not reliably fire when another process appends to a file — a long-standing platform gap, documented in nodejs/node#36888 and the original nodejs/node-v0.x-archive#1358.
This is not just a test bug: any Windows user running bitsocial logs -f against a running daemon log file would see the same silence.
Fix
Replace fs.watchFile with a userspace self-rescheduling setTimeout poll that calls fs.promises.stat() + reads new bytes when the size grows. This is the pattern used by production tail-f libraries (@logdna/tail-file, etc.) precisely because OS file-watcher events aren't cross-platform reliable for this scenario. CPU/IO profile is equivalent to the current setup (we were already polling — just inside libuv).
No new dependency; isolated change to src/cli/commands/logs.ts. The existing failing test serves as the regression test.
Bug
On Windows,
bitsocial logs -f(follow mode) does not emit new lines that another process appends to the current log file. The CLI emits the initial dump and then sits silent, even after the file size visibly grows.Linux and macOS behave correctly.
Repro / evidence
The test
continues watching old file if no new file appears(test/cli/logs.test.ts:462) reliably fails on Windows in CI:The assertion:
The test:
bitsocial logs -fagainst it.APPENDED_LINEto the same file.APPENDED_LINEwithin 8 seconds.On Windows the CLI runs the full 8s without emitting the appended line. Linux and macOS pass.
Root cause
src/cli/commands/logs.tsusesfs.watchFile(currentLogFile, { interval: 300 }, readNewData)to detect new bytes.fs.watchFileis backed by libuv'suv_fs_poll_t. On Windows, this notification mechanism does not reliably fire when another process appends to a file — a long-standing platform gap, documented in nodejs/node#36888 and the original nodejs/node-v0.x-archive#1358.This is not just a test bug: any Windows user running
bitsocial logs -fagainst a running daemon log file would see the same silence.Fix
Replace
fs.watchFilewith a userspace self-reschedulingsetTimeoutpoll that callsfs.promises.stat()+ reads new bytes when the size grows. This is the pattern used by production tail-f libraries (@logdna/tail-file, etc.) precisely because OS file-watcher events aren't cross-platform reliable for this scenario. CPU/IO profile is equivalent to the current setup (we were already polling — just inside libuv).No new dependency; isolated change to
src/cli/commands/logs.ts. The existing failing test serves as the regression test.