fix(desktop): rotate backend.log instead of truncating it on launch - #298
Merged
Conversation
fs::File::create zeroed the previous session's log on every launch. The natural response to a crashed session is "restart and retry" -- which destroyed exactly the evidence needed to diagnose the crash (the Mac Mini "audio processing failed" report had nothing to paste because of this). backend.log now rotates to backend.log.1 / backend.log.2 (oldest dropped) before the new session opens it. All renames are best-effort: a locked file on Windows must never block launch -- worst case we append to the old file, which still beats truncating it. The oldest generation is removed first because Windows fs::rename fails when the destination exists. Closes #278
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #278. Phase 1 of #272 — plan: #272 (comment) (PR-1B).
What
prepare_backend_stdioranfs::File::create(log_path), truncating the previous session'sbackend.logon every launch. The natural user response to a crash is "restart and retry" — which erased exactly the evidence needed to diagnose it (this is why the Mac Mini "Audio processing failed" reporter had nothing to paste).New
rotate_log(log_path, 3):backend.log→backend.log.1→backend.log.2, oldest dropped, then the session opens a fresh append-mode log as before.Two Windows-specific details handled:
fs::renamefails when the destination exists on Windows → the oldest generation isremove_file'd first, then the rest shift up.let _ =) — a locked file must never block app launch; worst case we append to the old log, which still beats truncating it.Validation
cargo clippyvia WSL: compiles clean; the 3 existing warnings are pre-existing (main.rs:72/232/972), none in this change. (PR CI does not build the Rust desktop app.)backend.log.1holds the prior session.🤖 Generated with Claude Code