Skip to content

fix(gateway): restart on WhatsApp bridge child exit (salvage #2324)#2334

Merged
teknium1 merged 1 commit intomainfrom
hermes/hermes-5e6ebebb
Mar 21, 2026
Merged

fix(gateway): restart on WhatsApp bridge child exit (salvage #2324)#2334
teknium1 merged 1 commit intomainfrom
hermes/hermes-5e6ebebb

Conversation

@teknium1
Copy link
Copy Markdown
Contributor

Summary

Salvage of PR #2324 by @ifrederico, cherry-picked onto current main.

When the WhatsApp gateway manages a Node.js bridge child process and that process exits after startup, the Python gateway previously kept running with every poll/send failing forever. This fix:

  • Adds _check_managed_bridge_exit() to detect managed bridge child exit via poll()
  • Checks it in all send/poll/get_chat_info paths (7 call sites)
  • Surfaces the exit as a retryable fatal adapter error (whatsapp_bridge_exited)
  • Makes the gateway exit non-zero so systemd Restart=on-failure can recover it
  • Replaces direct _running assignment with _mark_connected() / _mark_disconnected() base adapter methods

Pairs with the recently merged #2319 (systemd restart rate limiting) to prevent restart storms.

Verification

  • All 5692 tests pass
  • PR-specific tests: 24/24 pass
  • No internal looping risk: _set_fatal_error sets _running=False immediately, has_fatal_error guard prevents double-notification

Credit

Original work by @ifrederico in #2324. Contributor authorship preserved via cherry-pick.

@teknium1 teknium1 merged commit 8304a77 into main Mar 21, 2026
outsourc-e pushed a commit to outsourc-e/hermes-agent that referenced this pull request Mar 26, 2026
Co-authored-by: Frederico Ribeiro <fr@tecompanytea.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants