fix(host-service): classify a vanished local address as the cloud being unreachable

Merged
SU
12d ago
+2-0

Problem

host.info reports a 500 to Sentry when the TLS socket to the cloud API fails a read with EADDRNOTAVAIL. In the last 30 days this occurred about 32 times on about 20 different machines, in every release from 1.29 to 1.39. It is spread across the fetch failed issues for host.info (mostly HOST-SERVICE-1B, also HOST-SERVICE-7Y and HOST-SERVICE-A2).

Root cause

rethrowCloudUnreachable already maps transport failures to SERVICE_UNAVAILABLE, so the Sentry middleware does not report the user's network as a host-service bug (#6735, #7680, #8725). EADDRNOTAVAIL is not in UNREACHABLE_CODES. On a read of an established socket, it means the local address the socket used is no longer valid: the network interface changed or lost its address. host-service does not bind outbound sockets to a local address, so this code describes the host's network, not our software.

Fix

Add EADDRNOTAVAIL to UNREACHABLE_CODES, and add a row to the existing table test. This is the same shape as #7680 (ENOTCONN). The existing negative tests are not changed: an error with no code, an HTML body, an expired certificate, and application errors from the cloud API still report.

Verification

New test row fails before the change:

(fail) rethrowCloudUnreachable > EADDRNOTAVAIL is the cloud being unreachable
 25 pass
 1 fail

After:

$ bunx biome check packages/host-service/src/trpc/router/host/cloud-api-error.ts packages/host-service/src/trpc/router/host/cloud-api-error.test.ts
Checked 2 files in 73ms. No fixes applied.

$ cd packages/host-service && bun run typecheck
exit 0

$ bun test src/trpc/router/host
 31 pass
 0 fail
 50 expect() calls
Ran 31 tests across 2 files.

Refs HOST-SERVICE-A2


Summary by cubic

Marks EADDRNOTAVAIL as the cloud being unreachable so host.info no longer reports a 500 to Sentry when a TLS read fails because the local network interface lost its address (Wi-Fi change, sleep/wake, VPN toggle). The error is now mapped to SERVICE_UNAVAILABLE like other transport failures, with a new table test row covering it.

Summary by CodeRabbit

  • Bug Fixes
    • Cloud connection errors caused by unavailable network addresses are now reported as service unavailable, with the underlying error message preserved.