Skip to content

Commit 6b15e77

Browse files
committed
Fix localhost readiness checks for IPv6-only servers
1 parent db4c3ad commit 6b15e77

1 file changed

Lines changed: 9 additions & 14 deletions

File tree

react_on_rails/lib/react_on_rails/dev/server_manager.rb

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -896,17 +896,6 @@ def browser_auto_open_allowed?
896896
!ENV.key?("CI") && $stdin.tty? && $stdout.tty?
897897
end
898898

899-
def wait_for_server_on_port(port)
900-
deadline = Process.clock_gettime(Process::CLOCK_MONOTONIC) + OPEN_BROWSER_WAIT_TIMEOUT
901-
902-
loop do
903-
return true if localhost_port_open?(port)
904-
return false if Process.clock_gettime(Process::CLOCK_MONOTONIC) >= deadline
905-
906-
sleep OPEN_BROWSER_POLL_INTERVAL
907-
end
908-
end
909-
910899
def wait_for_app_route(port, request_path)
911900
deadline = Process.clock_gettime(Process::CLOCK_MONOTONIC) + OPEN_BROWSER_WAIT_TIMEOUT
912901

@@ -926,10 +915,16 @@ def app_route_ready?(port, request_path)
926915
end
927916

928917
def http_get_localhost(port, request_path)
929-
Net::HTTP.start("127.0.0.1", port, open_timeout: 1, read_timeout: 1) do |http|
930-
http.get(request_path)
918+
%w[127.0.0.1 ::1].each do |host|
919+
response = Net::HTTP.start(host, port, open_timeout: 1, read_timeout: 1) do |http|
920+
http.get(request_path)
921+
end
922+
923+
return response
924+
rescue StandardError
925+
next
931926
end
932-
rescue StandardError
927+
933928
nil
934929
end
935930

0 commit comments

Comments
 (0)