Files
Jinwoo-HandOrca eb0f0dbd50 fix(relay): cap relay.log via truncate-in-place when rename is blocked
Self-review found a HIGH cross-platform bug: on Windows the launch shell holds
its own `1>relay.log` handle without FILE_SHARE_DELETE, so renameSync of the
live file fails (EPERM/EBUSY). The previous rotate() swallowed that, reopened the
un-renamed file, and re-read its full over-cap size — so the cap never held on
Windows AND every subsequent log line churned a failing close/rename/open.

On rename failure, fall back to truncating relay.log in place ('w') so the size
cap still holds and there is no per-line churn. The shell's fd keeps appending at
its own offset but truncation bounds total growth; trade-off is no archived
generation on that path. New test models the rename-blocked case (archive path is
a directory) and asserts the cap still holds (fails pre-fix: 20100 > 4096).

Also fixed a test nit: spy on process.stderr so the post-restore assertion write
does not leak to the real test-runner stderr.

Co-authored-by: Orca <help@stably.ai>
2026-07-10 05:55:06 -04:00
..