openclaw - ✅(Solved) Fix [Bug]: Unhandled EHOSTUNREACH in SSRF/Telegram module causes Gateway crash [1 pull requests, 1 comments, 2 participants]

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…
GitHub stats
openclaw/openclaw#71529Fetched 2026-04-26 05:11:51
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
0
Participants
Timeline (top)
closed ×1commented ×1cross-referenced ×1

When the host network is temporarily unreachable (e.g., ISP hiccup, DNS timeout), the SSRF/Telegram module in the Gateway throws an unhandled EHOSTUNREACH error that crashes the entire Gateway process.

Error Message

Error: connect EHOSTUNREACH <ip>:443
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:... )

(Full stack trace involves the SSRF module's fetch/request path to Telegram API)

Root Cause

When the host network is temporarily unreachable (e.g., ISP hiccup, DNS timeout), the SSRF/Telegram module in the Gateway throws an unhandled EHOSTUNREACH error that crashes the entire Gateway process.

Fix Action

Fixed

PR fix notes

PR #71564: fix(gateway): suppress transient network errors in uncaughtException handler (#71529)

Description (problem / solution / changelog)

Summary

Fixes #71529 — The gateway crashes with EHOSTUNREACH during transient network hiccups because the uncaughtException handler unconditionally calls process.exit(1).

Root Cause

The unhandledRejection handler already uses isTransientUnhandledRejectionError() to suppress transient network errors (EHOSTUNREACH, ECONNRESET, ETIMEDOUT, etc.) and continue running. However, the uncaughtException handler in both src/index.ts and src/cli/run-main.ts has no such check — it crashes for all errors.

When a socket error event fires synchronously (e.g., EHOSTUNREACH from the Telegram/SSRF module during a network hiccup), it surfaces as an uncaughtException rather than an unhandledRejection, bypassing the transient-error suppression and crashing the gateway.

Fix

Apply the same isTransientUnhandledRejectionError() check to both uncaughtException handlers. Transient network errors are now logged as warnings and suppressed, matching the behavior of unhandledRejection.

Files Changed

  • src/index.ts — legacy CLI entry uncaughtException handler
  • src/cli/run-main.ts — main CLI entry uncaughtException handler

Testing

  • Transient network error (EHOSTUNREACH) → logged as warning, gateway continues ✅
  • Fatal errors (ERR_OUT_OF_MEMORY, etc.) → still crash with exit(1) ✅
  • Existing unhandled-rejections.test.ts suite unaffected ✅

Changed files

  • src/cli/run-main.ts (modified, +8/-1)
  • src/index.ts (modified, +11/-1)

Code Example

Error: connect EHOSTUNREACH <ip>:443
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:... )
RAW_BUFFERClick to expand / collapse

Bug type

Stability bug (crash)

Summary

When the host network is temporarily unreachable (e.g., ISP hiccup, DNS timeout), the SSRF/Telegram module in the Gateway throws an unhandled EHOSTUNREACH error that crashes the entire Gateway process.

Steps to reproduce

  1. Run OpenClaw Gateway as a LaunchAgent service
  2. Experience a temporary network interruption (ISP-level, not just Telegram API outage)
  3. Observe: Gateway crashes with uncaught exception in SSRF module

Expected behavior

Gateway should catch EHOSTUNREACH and other transient network errors gracefully — log the error, back off, and retry — without crashing the process.

Actual behavior

Gateway process crashes. Requires LaunchAgent KeepAlive: true to auto-restart, which creates a brief service interruption for all connected channels.

Environment

  • OpenClaw: 2026.4.23 (a979721)
  • OS: macOS 26.3 (arm64)
  • Install: Homebrew package
  • Channel: Telegram (likely affects all channels using SSRF)

Logs

Error: connect EHOSTUNREACH <ip>:443
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:... )

(Full stack trace involves the SSRF module's fetch/request path to Telegram API)

Impact

Any transient network hiccup causes a full Gateway restart, disrupting all active sessions and in-progress tool calls. With LaunchAgent watchdog this auto-recovers, but the interruption is non-trivial during active work.

extent analysis

TL;DR

Catch and handle the EHOSTUNREACH error in the SSRF/Telegram module to prevent the Gateway process from crashing.

Guidance

  • Identify the specific code path in the SSRF module where the EHOSTUNREACH error occurs and add error handling to catch this exception.
  • Implement a retry mechanism with exponential backoff to handle transient network errors without crashing the Gateway process.
  • Review the Gateway's error logging to ensure that such errors are properly logged for debugging and monitoring purposes.
  • Consider adding a circuit breaker pattern to detect and prevent further requests when the network is temporarily unreachable.

Example

try {
  // existing code that throws EHOSTUNREACH
} catch (error) {
  if (error.code === 'EHOSTUNREACH') {
    // log the error and retry with backoff
    console.error('Transient network error:', error);
    // implement retry logic here
  } else {
    throw error;
  }
}

Notes

The provided solution assumes that the EHOSTUNREACH error is thrown by the net module in Node.js. The actual implementation may vary depending on the specific requirements and constraints of the OpenClaw Gateway project.

Recommendation

Apply a workaround by catching and handling the EHOSTUNREACH error in the SSRF/Telegram module, as this will prevent the Gateway process from crashing due to transient network errors.

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…

FAQ

Expected behavior

Gateway should catch EHOSTUNREACH and other transient network errors gracefully — log the error, back off, and retry — without crashing the process.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix [Bug]: Unhandled EHOSTUNREACH in SSRF/Telegram module causes Gateway crash [1 pull requests, 1 comments, 2 participants]