Reproduce #624 race condition via real server crash#626
Draft
Conversation
…as strict xfail why: The previous test looped new_session() 10 times hoping to trigger a timing race, but the bug is deterministic in PyInstaller + Python 3.13 + Docker environments (LD_LIBRARY_PATH contamination crashes tmux server after new-session returns, causing list-sessions to miss the session). what: - Replace loop-based test with monkeypatch that intercepts neo.fetch_objs - Return empty list on first list-sessions call, simulating stale response - Add strict=True so XPASS signals when retry-based fix is added - Keep real tmux new-session execution to validate integration - Add precise type annotations matching neo.fetch_objs signature
why: Previous test monkeypatched fetch_objs to return [], bypassing all real tmux interaction. This version exercises the full code path with real tmux commands — only crash timing is controlled. what: - Kill real tmux server inside fetch_objs wrapper, start replacement - Bumper session ensures session_id mismatch (original $1 vs replacement $0) - All 7 code paths exercised: new-session, kill-server, replacement new-session, list-sessions, fetch_objs parsing, fetch_obj search, TmuxObjectDoesNotExist
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #626 +/- ##
==========================================
+ Coverage 45.39% 45.48% +0.08%
==========================================
Files 22 22
Lines 2249 2249
Branches 360 360
==========================================
+ Hits 1021 1023 +2
+ Misses 1082 1081 -1
+ Partials 146 145 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Summary
test_new_session_race_conditionthat reproduces Race condition in new_session() in some environments (e.g. PyInstaller + Python 3.13+ + Docker) #624 by injecting a real tmux server crash betweennew-sessionandlist-sessionsstrict=Truexfail: will flip to XPASS when retry logic is added (the fix)Related:
How it works
race_testgets$1server.new_session("race_test")runs realtmux new-session→ returns$1fetch_objsintercepts the firstlist-sessionscall: kills the server, starts a replacement (which gets$0)fetch_objsrunslist-sessionsagainst the replacement server — finds only$0fetch_objsearches for$1, doesn't find it →TmuxObjectDoesNotExistTest plan
uv run pytest tests/test_server.py::test_new_session_race_condition -xvs→ XFAILuv run ruff check tests/test_server.py→ cleanuv run mypy tests/test_server.py→ cleanuv run pytest tests/test_server.py -v→ 29 passed, 1 skipped, 1 xfailed