fix(core): survive concurrent Windows log cleanup - #1218
Merged
Conversation
Windows log files are per-PID, so every launch prunes the same shared directory, and concurrent launches are the normal case for the Claude Code plugin: several editor sessions plus a session-start hook each start a process. The unlink in _cleanup_windows_log_files is guarded against another launch removing a file first; the stat in the sort key that precedes it was not, so FileNotFoundError escaped through setup_logging and ended the process during logging setup. When that process was the MCP server, the client saw the stdio connection close a couple of seconds after launch and the session silently had no basic-memory tools, while the bundled skills and slash commands went on instructing against tools that were not there. The sort key now treats a file that has already gone as oldest, which puts it in the delete slice, where unlink is already guarded against the same race. The test stands in for the racing launch by deleting the file during the stat it is about to be sorted by. Signed-off-by: overgoy <32526203+overgoy@users.noreply.github.com> (cherry picked from commit a00200e)
Signed-off-by: phernandez <paul@basicmachines.co>
This was referenced Aug 9, 2026
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.
Why
FileNotFoundErrorto escape from logging setup and terminate startup.Path.stat()on the supported Python 3.12 runtime.What Changed
stat.Implementation Details
a00200e624162c62bfef6d00b44ba28d9030c7adwithcherry-pick -x.main, so it also includes changes landed after the contributor branch was created.Testing
Automated
uv run --python 3.12 pytest tests/utils/test_setup_logging.py::test_setup_logging_survives_a_stale_log_deleted_mid_cleanup -qbefore the maintainer fix: reproducedRecursionError.uv run --python 3.12 pytest tests/utils/test_setup_logging.py -q: 10 passed.uv run pytest tests/utils/ -q: 166 passed.just fast-check: passed.Manual
Risks / Follow-ups