#3831: fix: ignore mDNS socket errors to prevent gateway crashes
Cluster:
Gateway Resilience and Configuration
## Problem
Gateway crashes every ~2 minutes due to unhandled promise rejection from mDNS announcement failures (EAFNOSUPPORT socket errors).
## Solution
Extended `ignoreCiaoCancellationRejection` to also handle mDNS socket errors, which are non-fatal and typically caused by network interface configuration issues.
## Testing
- Tested locally: gateway remained stable for 150+ seconds after fix, compared to crashing every ~120 seconds before
- Environment: macOS 15.2, with HTTP_PROXY configuration
## Notes
- These socket errors don't affect gateway functionality since mDNS is only for local network discovery
- Gateway continues to work normally even when mDNS is unavailable
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR updates the unhandled-rejection filter used by the Bonjour/mDNS advertiser so that certain `@homebridge/ciao` promise rejections are treated as non-fatal. Specifically, `ignoreCiaoCancellationRejection()` now explicitly ignores the normal “announcement cancelled” rejection and additionally tries to ignore mDNS announcement socket errors, preventing the gateway from crashing due to unhandled rejections during mDNS advertising.
This fits into the existing startup flow in `src/infra/bonjour.ts`, where an unhandled rejection handler is registered when services are created and advertising is intentionally done “fire-and-forget” so the gateway can still start even if Bonjour fails.
<h3>Confidence Score: 4/5</h3>
- Likely safe to merge; change is localized and defensive, but string-matching may not cover the reported errors reliably.
- The PR only adjusts a boolean filter for unhandled rejections and adds debug logging; there are no API or control-flow changes outside this handler. Main concern is correctness of the new error matching: if the ciao error message differs (common across OS/network configurations), the gateway could still see unhandled rejections.
- src/infra/bonjour-ciao.ts
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#4653: fix(gateway): improve crash resilience for mDNS and network errors
by AyedAlmudarra · 2026-01-30
88.7%
#17257: fix(bonjour): stop mDNS flood on multi-NIC same-LAN setups (#17222)
by yinghaosang · 2026-02-15
80.9%
#10034: Don't crash gateway on transient unhandled fetch failures
by gigq · 2026-02-06
79.1%
#11101: fix: handle AbortError and WebSocket 1006 in unhandled rejection ha...
by Nipurn123 · 2026-02-07
78.5%
#8260: fix(macOS): gateway readiness detection + reversible Configure later
by xksteven · 2026-02-03
75.9%
#7558: fix: Handle Grammy/Telegram network errors to prevent gateway crashes
by kaigritun · 2026-02-03
75.5%
#8745: fix(gateway): respect gateway.port config and --port CLI flag
by revenuestack · 2026-02-04
75.2%
#7563: fix: expand transient network error detection
by kaigritun · 2026-02-03
75.2%
#6302: fix: Add timeouts to prevent indefinite hangs (issues #4954, #4956,...
by batumilove · 2026-02-01
74.9%
#17758: Fix crash on transient Discord gateway zombie connection errors
by DoyoDia · 2026-02-16
74.8%