hermes - 💡(How to fix) Fix WhatsApp bridge opens blank node.exe console window on Windows [2 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

ERROR gateway.platforms.whatsapp: [Whatsapp] WhatsApp bridge process exited unexpectedly (code 3221225786). ERROR gateway.run: Fatal whatsapp adapter error (whatsapp_bridge_exited): WhatsApp bridge process exited unexpectedly (code 3221225786).

Root Cause

Likely Root Cause

Fix Action

Fixed

Code Example

node C:\Users\<user>\AppData\Local\hermes\hermes-agent\scripts\whatsapp-bridge\bridge.js --port 3000 --session C:\Users\<user>\AppData\Local\hermes\whatsapp\session --mode self-chat

---

ERROR gateway.platforms.whatsapp: [Whatsapp] WhatsApp bridge process exited unexpectedly (code 3221225786).
ERROR gateway.run: Fatal whatsapp adapter error (whatsapp_bridge_exited): WhatsApp bridge process exited unexpectedly (code 3221225786).
INFO gateway.run: whatsapp queued for background reconnection
INFO gateway.run: Reconnecting whatsapp (attempt 1)...

---

self._bridge_process = subprocess.Popen(
    ["node", str(bridge_path), ...],
    stdout=bridge_log_fh,
    stderr=bridge_log_fh,
    preexec_fn=None if _IS_WINDOWS else os.setsid,
    env=bridge_env,
)

---

popen_kwargs = {
    "stdout": bridge_log_fh,
    "stderr": bridge_log_fh,
    "env": bridge_env,
}
if _IS_WINDOWS:
    popen_kwargs["creationflags"] = getattr(subprocess, "CREATE_NO_WINDOW", 0x08000000)
else:
    popen_kwargs["preexec_fn"] = os.setsid

self._bridge_process = subprocess.Popen(
    ["node", str(bridge_path), "--port", str(self._bridge_port), "--session", str(self._session_path), "--mode", whatsapp_mode],
    **popen_kwargs,
)
RAW_BUFFERClick to expand / collapse

Bug Description

On Windows, enabling the WhatsApp gateway platform launches the Node.js WhatsApp bridge in a visible blank console window.

The bridge stdout/stderr are already redirected to whatsapp/bridge.log, so the console contains no useful output. If the user closes the blank console window, the bridge exits with Windows status 0xC000013A (3221225786), and the gateway reconnection watcher starts it again, causing the blank node.exe window to reappear.

Steps to Reproduce

  1. Run Hermes Gateway on Windows with the WhatsApp platform enabled.
  2. Wait for the WhatsApp adapter to start the Node bridge: scripts/whatsapp-bridge/bridge.js
  3. Observe a visible blank node.exe console window.
  4. Close that console window.
  5. Observe the gateway logs and reconnection watcher relaunching the bridge.

Expected Behavior

The WhatsApp bridge should run hidden/backgrounded on Windows, with output going to whatsapp/bridge.log, and no blank console window should appear.

Actual Behavior

A blank node.exe console window appears. Closing it kills the bridge, then Hermes relaunches it.

Observed process command line:

node C:\Users\<user>\AppData\Local\hermes\hermes-agent\scripts\whatsapp-bridge\bridge.js --port 3000 --session C:\Users\<user>\AppData\Local\hermes\whatsapp\session --mode self-chat

Observed gateway log:

ERROR gateway.platforms.whatsapp: [Whatsapp] WhatsApp bridge process exited unexpectedly (code 3221225786).
ERROR gateway.run: Fatal whatsapp adapter error (whatsapp_bridge_exited): WhatsApp bridge process exited unexpectedly (code 3221225786).
INFO gateway.run: whatsapp queued for background reconnection
INFO gateway.run: Reconnecting whatsapp (attempt 1)...

Likely Root Cause

gateway/platforms/whatsapp.py starts the bridge with subprocess.Popen(...) and redirects stdout/stderr, but does not pass a Windows creationflags value.

Current shape around the bridge launch:

self._bridge_process = subprocess.Popen(
    ["node", str(bridge_path), ...],
    stdout=bridge_log_fh,
    stderr=bridge_log_fh,
    preexec_fn=None if _IS_WINDOWS else os.setsid,
    env=bridge_env,
)

On Windows, launching a console subsystem executable like node.exe from a pythonw.exe gateway process can still allocate/show a new console window unless CREATE_NO_WINDOW is used.

Suggested Fix

Use subprocess.CREATE_NO_WINDOW when _IS_WINDOWS, while preserving os.setsid for POSIX:

popen_kwargs = {
    "stdout": bridge_log_fh,
    "stderr": bridge_log_fh,
    "env": bridge_env,
}
if _IS_WINDOWS:
    popen_kwargs["creationflags"] = getattr(subprocess, "CREATE_NO_WINDOW", 0x08000000)
else:
    popen_kwargs["preexec_fn"] = os.setsid

self._bridge_process = subprocess.Popen(
    ["node", str(bridge_path), "--port", str(self._bridge_port), "--session", str(self._session_path), "--mode", whatsapp_mode],
    **popen_kwargs,
)

Hermes already uses this pattern elsewhere on Windows, e.g. hermes_cli/gateway_windows.py for avoiding console flashes.

Environment

  • OS: Windows 10
  • Hermes install path: %LOCALAPPDATA%\hermes\hermes-agent
  • Gateway started via scheduled task / pythonw.exe -m hermes_cli.main gateway run --replace
  • WhatsApp platform enabled

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - 💡(How to fix) Fix WhatsApp bridge opens blank node.exe console window on Windows [2 pull requests]