Skip to content

Gateway crashes on ENETUNREACH — uncaught network exception kills entire process #67944

Description

@fwends

Summary

The gateway process exits with code 1 when a single outbound connection hits ENETUNREACH. A momentary network unreachability (e.g. Telegram's IP briefly unavailable) causes the entire gateway to crash, disconnecting all agents and sessions.

Error from log

2026-04-16T18:44:37.946+07:00 [openclaw] Uncaught exception: Error: connect ENETUNREACH 149.154.167.220:443 - Local (0.0.0.0:62855)
    at internalConnect (node:net:1110:16)
    ...
    at connect (/Users/greg/codebase/openclaw/node_modules/undici/lib/core/connect.js:70:20)
ELIFECYCLE  Command failed with exit code 1.

149.154.167.220 is a Telegram API IP. The connection error bubbled up as an uncaught exception and terminated the Node process.

Impact

  • All TUI clients show "gateway disconnected: closed | idle"
  • All agent sessions drop — "not connected to gateway — message not sent"
  • Gateway must be manually restarted
  • Any in-progress agent work is lost

Expected behavior

A failed outbound network connection (even a persistent one) should be caught and handled gracefully — log the error, back off and retry, and keep the gateway running. A single provider's network being temporarily unreachable should never take down the whole process.

Steps to reproduce

  1. Run gateway with Telegram connected
  2. Briefly interrupt network connectivity to Telegram's IPs (or have ISP/routing hiccup)
  3. Gateway exits immediately

Suggested fix

  • Wrap the Telegram connection/polling loop in a try/catch or attach an error event handler on the underlying socket/agent so ENETUNREACH is caught at the connection level
  • Add a top-level process.on('uncaughtException') handler that logs the error and decides whether it is fatal rather than always crashing
  • Alternatively, wrap outbound requests in a circuit breaker that absorbs transient network errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions