fix(whatsapp): spawn bridge with proper Windows detach flags to prevent console flash and STATUS_CONTROL_C_EXIT crashes - #60516
Conversation
…nt console flash and STATUS_CONTROL_C_EXIT crashes On Windows, start_new_session=True is a no-op for subprocess.Popen. Without proper creationflags, the bridge inherits the parent console, causing a visible cmd window flash and periodic crashes from group CTRL events (exit code 0xC000013A). This fix adds creationflags=windows_detach_flags_without_breakaway() which applies CREATE_NEW_PROCESS_GROUP | DETACHED_PROCESS | CREATE_NO_WINDOW to spawn the bridge as a detached background daemon. Sibling call sites already use windows_hide_flags() for short-lived console processes; the bridge spawn site was missed.
Competing with #59285 (vizi0uz) for the same issue (#60508). Both add Windows detach flags to the WhatsApp bridge spawn in |
|
This PR is not a duplicate of #59285. While both address issue #60508 (WhatsApp bridge console window on Windows), they use different technical approaches:
Per the issue reporter's analysis:
This PR implements the issue reporter's suggested fix to avoid that PermissionError scenario. The approaches target different Windows process spawning constraints and are not mutually exclusive duplicates — they represent alternative solutions for different deployment contexts. |
|
Thanks for this PR — the underlying bug (WhatsApp bridge spawning Node with a visible console window on Windows) is now fixed on main via #60924, a salvage of #60647 which swaps the bare |
What does this PR do?
Fixes a Windows-specific issue where the WhatsApp bridge subprocess (
node bridge.js) spawns with a visible console window and crashes every ~2 minutes with exit code0xC000013A(STATUS_CONTROL_C_EXIT) on native Windows.On Windows,
start_new_session=Trueis a no-op forsubprocess.Popen(perhermes_cli/_subprocess_compat.py). Without propercreationflags, the bridge process inherits the parent's console, causing:cmd.exewindow that flashes briefly at startupThe fix adds
creationflags=windows_detach_flags_without_breakaway(), which appliesCREATE_NEW_PROCESS_GROUP | DETACHED_PROCESS | CREATE_NO_WINDOWon Windows to spawn the bridge as a true detached background daemon without a console window.Sibling call sites at lines 91/102 already use
windows_hide_flags()for short-lived console processes; the bridge spawn site (line ~656) was missed.Related Issue
Fixes #60508
Type of Change
Changes Made
plugins/platforms/whatsapp/adapter.py: Importwindows_detach_flags_without_breakawayand addcreationflagsparameter to the bridgesubprocess.Popen()callHow to Test
This change is Windows-specific; the macOS host cannot reproduce the original symptom. The fix is a one-line addition of well-tested subprocess compatibility flags.
Verification path:
Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/A