fix(whatsapp): hide bridge console window on Windows - #60605
Conversation
The Node WhatsApp bridge is spawned with start_new_session=True, which is a no-op on Windows (subprocess silently ignores it), so the long-lived bridge pops a visible black console window. Other subprocess calls in this file already use windows_hide_flags() (CREATE_NO_WINDOW); apply it to the bridge spawn too. Returns 0 on POSIX, so it is a no-op there. Output still routes to the bridge log file, so stdio capture is unaffected.
Competing fix cluster for the WhatsApp bridge console window on Windows (issue #60508 / closed #29715). Three OPEN PRs:
All fix the same symptom; #59285 is the more complete fix (hide + detach addresses the crash-loop, not just the visible window). Flagging for a maintainer to pick one. |
|
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 |
Summary
On Windows the WhatsApp bridge (
node.exe ... whatsapp-bridge/bridge.js) is spawned withstart_new_session=True, which is a no-op on Windows —subprocessaccepts the kwarg but ignores it, so the long-lived bridge pops a visible black console window. Closing it kills the bridge, and the gateway's reconnection watcher relaunches it, so it never stays closed.Other subprocess calls in the same file (
_kill_stale_bridge_by_pidfile,_kill_port_process) already usewindows_hide_flags()(CREATE_NO_WINDOW); the bridge spawn simply omitted it.Change
Add
creationflags=windows_hide_flags()to the bridgePopen.windows_hide_flags()returns0on POSIX, so this is a no-op there. Bridge output still routes to the log file, so stdio capture is unaffected.Verification
MainWindowHandle=0(no window) and the gateway logs✓ whatsapp connected.tests/gateway/test_whatsapp_connect.py(29 tests),test_whatsapp_stale_bridge.py,test_whatsapp_reply_prefix.pypass.test_whatsapp_bridge_pidfile.py::TestKillPortProcess::test_kill_port_spares_client_processis pre-existing flaky on Windows (real socket +taskkilltiming) — fails identically on unmodified code.🤖 Generated with Hermes Agent