#7675: fix: handle network interface retrieval errors in resolvePrimaryIPv4
stale
Cluster:
Gateway Error Handling Improvements
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR wraps `os.networkInterfaces()` in `resolvePrimaryIPv4()` with a `try/catch` and falls back when network interface enumeration fails, preventing crashes during self-presence initialization.
The change lives in `src/infra/system-presence.ts`, which seeds a local “gateway self” presence entry at module init and uses the resolved IPv4 address to populate the `ip` field and display text.
<h3>Confidence Score: 4/5</h3>
- This PR is likely safe to merge and reduces crash risk, with a small behavioral ambiguity around the `ip` fallback value.
- The change is localized and defensive, but the new fallback path returns a hostname in a function used to populate an `ip` field, which could confuse downstream consumers or UI formatting.
- src/infra/system-presence.ts
<!-- 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))
- Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13))
<!-- /greptile_comment -->
Most Similar PRs
#7060: fix: handle uv_interface_addresses failure on Android/Termux
by kjoh94 · 2026-02-02
82.3%
#10030: Guard network interface enumeration
by TheAxumite · 2026-02-06
81.7%
#6113: support ipv6
by DingProg · 2026-02-01
77.5%
#7563: fix: expand transient network error detection
by kaigritun · 2026-02-03
76.4%
#4653: fix(gateway): improve crash resilience for mDNS and network errors
by AyedAlmudarra · 2026-01-30
73.4%
#4243: fix: resolve Node.js punycode deprecation warning
by dylanneve1 · 2026-01-29
72.0%
#10034: Don't crash gateway on transient unhandled fetch failures
by gigq · 2026-02-06
71.7%
#3831: fix: ignore mDNS socket errors to prevent gateway crashes
by cici1029 · 2026-01-29
71.6%
#13881: fix: Address Greptile feedback - test isolation and channel resolution
by trevorgordon981 · 2026-02-11
71.4%
#6110: refactor: simplify boolean logic using nullish coalescing
by T1mn · 2026-02-01
70.9%