Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion lib/daemon_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ def ping_socket(socket_domain, sockaddr)
raise Errno::ECONNREFUSED
end
end
true
socket_connected?(socket)
rescue Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::ENOENT
# ECONNRESET: the connection landed in the listen backlog of a
# server that closed its listening socket before accepting it,
Expand All @@ -715,6 +715,17 @@ def ping_socket(socket_domain, sockaddr)
socket.close if socket
end

# Some macOS systems (seen on warp CI runners in 2026) report a nonblocking
# connect to a closed TCP port as successful, so ping_socket confirms the
# connection by asking for the peer address. macOS fails that call with
# EINVAL instead of ENOTCONN when the connection attempt has failed.
def socket_connected?(socket)
socket.getpeername
true
rescue Errno::ENOTCONN, Errno::EINVAL
false
end

def ping_tcp_socket(sockaddr)
ping_socket(Socket::Constants::AF_INET, sockaddr)
rescue Errno::EAFNOSUPPORT
Expand Down