#7563: fix: expand transient network error detection
Cluster:
Network Error Handling Improvements
Add message-based detection for additional transient network errors:
- socket hang up
- network error/failure
- connection reset/timed out/refused
- dns lookup failed
- host not found
These errors are now logged as warnings instead of crashing the gateway, making OpenClaw resilient to unstable network connections (Starlink, mobile hotspots, etc).
Extends #7558, addresses #7474
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
Expands `isTransientNetworkError` to also detect transient network failures by scanning error message text (e.g., socket hang up, connection refused, DNS lookup failures), so these unhandled rejections are logged as warnings instead of crashing the gateway.
This change integrates into the existing unhandled rejection flow in `installUnhandledRejectionHandler`, which already treats aborts, fatal errors, and config errors specially; transient network errors now have broader coverage beyond just error codes and undici’s `fetch failed` wrapper.
<h3>Confidence Score: 4/5</h3>
- This PR is likely safe to merge after addressing a small runtime edge case in message inspection.
- The change is localized and conceptually straightforward, but the new `"message" in err` check can throw when `err` is a non-null primitive, which is plausible for `unhandledRejection` reasons and would undermine the resiliency goal.
- src/infra/unhandled-rejections.ts (message inspection in transient detection / abort detection)
<!-- greptile_other_comments_section -->
<sub>(4/5) You can add custom instructions or style guidelines for the agent [here](https://app.greptile.com/review/github)!</sub>
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
- Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13))
<!-- /greptile_comment -->
Most Similar PRs
#7558: fix: Handle Grammy/Telegram network errors to prevent gateway crashes
by kaigritun · 2026-02-03
81.6%
#11101: fix: handle AbortError and WebSocket 1006 in unhandled rejection ha...
by Nipurn123 · 2026-02-07
81.4%
#10034: Don't crash gateway on transient unhandled fetch failures
by gigq · 2026-02-06
80.9%
#23787: Handle transient Slack request errors without crashing the gateway
by graysurf · 2026-02-22
79.7%
#21163: Prevent Slack DNS errors from crashing the gateway
by graysurf · 2026-02-19
79.7%
#10030: Guard network interface enumeration
by TheAxumite · 2026-02-06
78.5%
#9232: Fix: Add automatic retry for network errors in message runs
by vishaltandale00 · 2026-02-05
78.4%
#7060: fix: handle uv_interface_addresses failure on Android/Termux
by kjoh94 · 2026-02-02
77.7%
#4036: fix: include cause detail in agent connection error diagnostic
by anajuliabit · 2026-01-29
77.5%
#4653: fix(gateway): improve crash resilience for mDNS and network errors
by AyedAlmudarra · 2026-01-30
77.5%