#7060: fix: handle uv_interface_addresses failure on Android/Termux
Cluster:
Gateway Error Handling Improvements
## Summary
- Android restricts the `uv_interface_addresses` system call, causing `os.networkInterfaces()` to throw at runtime
- Wrap calls in `system-presence.ts` and `tailnet.ts` with try/catch so the gateway and onboarding degrade gracefully instead of crashing
## Changes
- **`src/infra/system-presence.ts`** — Extract `safeNetworkInterfaces()` helper that returns `{}` on failure
- **`src/infra/tailnet.ts`** — Add try/catch in `listTailnetAddresses()`, return empty arrays on failure
## Environment variables (Termux users)
- `OPENCLAW_TS_COMPILER=tsc` — Avoids tsgo panic (missing bundled lib.d.ts on ARM/Termux)
- `OPENCLAW_DISABLE_BONJOUR=1` — Skips @homebridge/ciao mDNS which also calls os.networkInterfaces()
## Test plan
- Verified on Termux (Android 12, aarch64) — onboarding and gateway start without crash
- Existing tests pass (no behavior change on Linux/macOS where the syscall succeeds)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR adds guards around `os.networkInterfaces()` calls to prevent runtime crashes on Android/Termux where `uv_interface_addresses` can be restricted. `system-presence.ts` introduces a `safeNetworkInterfaces()` helper returning `{}` on failure, and `tailnet.ts` wraps interface enumeration in a try/catch and returns empty address lists when the syscall fails. These changes keep onboarding/gateway flows running by degrading network-derived features instead of crashing.
<h3>Confidence Score: 3/5</h3>
- This PR is likely safe to merge, with one functional concern around an incorrect fallback value and a couple diagnosability nits.
- The change is small and localized (try/catch around `os.networkInterfaces()`), and the intended behavior is to degrade gracefully on restricted platforms. The main potential bug is `resolvePrimaryIPv4()` returning `os.hostname()` which is not an IPv4 address and may be propagated as `ip` more often due to the new `{}` fallback. The remaining feedback is about silent error swallowing which may hinder debugging.
- src/infra/system-presence.ts (verify `resolvePrimaryIPv4` return semantics), src/infra/tailnet.ts (optional logging for unexpected failures).
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
<!-- /greptile_comment -->
Most Similar PRs
#10030: Guard network interface enumeration
by TheAxumite · 2026-02-06
83.1%
#7675: fix: handle network interface retrieval errors in resolvePrimaryIPv4
by cre47e · 2026-02-03
82.3%
#23326: fix(daemon): graceful degradation on unsupported platforms
by indistinctchatter604 · 2026-02-22
78.6%
#7563: fix: expand transient network error detection
by kaigritun · 2026-02-03
77.7%
#4653: fix(gateway): improve crash resilience for mDNS and network errors
by AyedAlmudarra · 2026-01-30
76.6%
#10034: Don't crash gateway on transient unhandled fetch failures
by gigq · 2026-02-06
75.6%
#8260: fix(macOS): gateway readiness detection + reversible Configure later
by xksteven · 2026-02-03
75.2%
#13881: fix: Address Greptile feedback - test isolation and channel resolution
by trevorgordon981 · 2026-02-11
74.8%
#11101: fix: handle AbortError and WebSocket 1006 in unhandled rejection ha...
by Nipurn123 · 2026-02-07
74.6%
#11048: fix: address repository issues (env, author, CI comments, security ...
by cavula · 2026-02-07
74.3%