summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Cleberg <[email protected]>2026-07-24 18:34:35 -0500
committerChristian Cleberg <[email protected]>2026-07-24 19:09:01 -0500
commit5fe3aeb2cefc41b8b96d99d47d967eb7aa070c98 (patch)
treecd8eb0360a075c24af2824817dc4a0312c891fc0
parent2ed92d773a2505ac3b6fbd3d280258549936ba2a (diff)
downloaddomain-dig-5fe3aeb2cefc41b8b96d99d47d967eb7aa070c98.tar.gz
domain-dig-5fe3aeb2cefc41b8b96d99d47d967eb7aa070c98.tar.bz2
domain-dig-5fe3aeb2cefc41b8b96d99d47d967eb7aa070c98.zip
fix: surface the real NWListener error and drop conflicting requiredLocalEndpoint (#30)
The Local API failed to start with a generic "Could not start Local API on port 47821" and no actionable cause. Two problems: 1. The NWListener construction catch discarded the caught error and substituted a generic string, so the real NWError was never surfaced or logged. Now the underlying error is logged via stateLogger (matching the .failed branch) and appended to the thrown message. 2. parameters.requiredLocalEndpoint pinned 127.0.0.1:<port> while the same port was passed as the listener's on: argument. Pinning a required local endpoint conflicts with the listener's own port assignment; acceptLocalOnly already constrains binding to the local link. Dropped requiredLocalEndpoint, keeping acceptLocalOnly + allowLocalEndpointReuse.
-rw-r--r--LocalAPIService.swift9
1 files changed, 4 insertions, 5 deletions
diff --git a/LocalAPIService.swift b/LocalAPIService.swift
index 7d42128..cd12fb8 100644
--- a/LocalAPIService.swift
+++ b/LocalAPIService.swift
@@ -372,10 +372,6 @@ private final class LocalAPIServer: @unchecked Sendable {
let parameters = NWParameters.tcp
parameters.acceptLocalOnly = true
parameters.allowLocalEndpointReuse = true
- parameters.requiredLocalEndpoint = .hostPort(
- host: .ipv4(IPv4Address.loopback),
- port: NWEndpoint.Port(rawValue: UInt16(port)) ?? .any
- )
let listener: NWListener
do {
@@ -384,7 +380,10 @@ private final class LocalAPIServer: @unchecked Sendable {
on: NWEndpoint.Port(rawValue: UInt16(port)) ?? .any
)
} catch {
- throw LocalAPIServerError.serverStartFailed("Could not start Local API on port \(port).")
+ stateLogger("Failed: \(error.localizedDescription)")
+ throw LocalAPIServerError.serverStartFailed(
+ "Could not start Local API on port \(port): \(error.localizedDescription)"
+ )
}
listener.newConnectionHandler = { [weak self] connection in