Skip to content

fix: WhatsApp bridge process leak and disable config asymmetry#19138

Closed
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:fix/whatsapp-disable-and-bridge-cleanup
Closed

fix: WhatsApp bridge process leak and disable config asymmetry#19138
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:fix/whatsapp-disable-and-bridge-cleanup

Conversation

@liuhao1024

Copy link
Copy Markdown
Contributor

Summary

Fixes two issues with WhatsApp platform:

1. Bridge Process Leak (PID file mechanism)

Problem: When the gateway restarts or crashes, old Node.js bridge processes become orphaned. The existing _kill_port_process() relies on fuser (Linux) which is often not available (e.g., WSL2, minimal installations), causing silent failures and process accumulation (up to 39 zombie processes observed).

Solution:

  • Added PID file mechanism (bridge.pid in session directory) to track bridge processes
  • _kill_stale_bridge_by_pidfile() kills orphaned bridges by PID before spawning new ones
  • _write_bridge_pidfile() records the bridge PID after spawning
  • PID file is cleaned up on graceful disconnect
  • Added lsof as fallback in _kill_port_process() when fuser is not available

2. Config Asymmetry (disable WhatsApp via config)

Problem: WhatsApp can only be enabled via WHATSAPP_ENABLED=true env var, but there's no way to disable it via CLI/UI. Setting whatsapp.enabled: false in config.yaml was ignored.

Solution:

  • Check config.yaml for WhatsApp settings first
  • Respect explicit disable: WHATSAPP_ENABLED=false env var or whatsapp.enabled: false in config.yaml
  • Only fall back to env var for enable if no YAML config exists

Testing

  • All WhatsApp tests pass (74 passed, 3 pre-existing flaky failures unrelated to changes)
  • Config tests pass
  • Syntax verified

Fixes #19124

- Add PID file mechanism to track bridge processes and kill stale ones on startup
- Improve _kill_port_process() with lsof fallback when fuser is not available
- Support explicit WhatsApp disable via config.yaml (whatsapp.enabled: false)
- Respect WHATSAPP_ENABLED=false env var to disable WhatsApp

Fixes NousResearch#19124
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/whatsapp WhatsApp Business adapter labels May 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/whatsapp WhatsApp Business adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WhatsApp platform cannot be disabled via UI/CLI + bridge process leak

2 participants