Skip to content

fix: session-abort race & strip __PYVENV_LAUNCHER__ for macOS#75

Merged
davidliuk merged 4 commits intomainfrom
fix/session-race-and-pyvenv
Mar 22, 2026
Merged

fix: session-abort race & strip __PYVENV_LAUNCHER__ for macOS#75
davidliuk merged 4 commits intomainfrom
fix/session-race-and-pyvenv

Conversation

@Zhang-Henry
Copy link
Copy Markdown
Collaborator

@Zhang-Henry Zhang-Henry commented Mar 22, 2026

Summary

  • Session-abort race fix: Defer removeSession / activeXxxSessions.delete until after the completion event is sent to the client, preventing a race where an abort request arrives between session cleanup and the completion message (Claude, Cursor, Gemini).
  • __PYVENV_LAUNCHER__ fix: Strip __PYVENV_LAUNCHER__ from the environment when spawning Python CLI subprocesses (xhs, twitter) on macOS so uv-installed tools find the correct stdlib instead of erroring with "No module named 'encodings'".

Test plan

  • Start a Claude/Gemini/Cursor session, abort mid-stream — verify no stale session state
  • Run X / Xiaohongshu search on macOS with uv-installed CLIs — verify no encodings import error
  • Verify normal session completion still works and sessions are cleaned up

Zhang-Henry and others added 4 commits March 22, 2026 00:06
…letion message

Move removeSession/delete calls after ws.send() in claude-sdk, gemini-cli,
and cursor-cli so abort requests arriving during the completion window still
find the session and return success instead of a misleading error.
On macOS, when a Python framework build (e.g. system Python 3.8) spawns a
subprocess that uses a different Python version (e.g. uv-installed 3.13),
the inherited __PYVENV_LAUNCHER__ variable causes the child interpreter to
look for its stdlib in the wrong prefix, failing with
"No module named 'encodings'".

Strip this variable in all three call sites: the Node.js spawn layer
(news.js) and both Python search scripts (search_xiaohongshu.py,
search_x.py).
@davidliuk
Copy link
Copy Markdown
Collaborator

LGTM, fixed a dual definition issue that block backend server.

@davidliuk davidliuk merged commit 8590bf7 into main Mar 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants