Skip to content

Commit 8b8730d

Browse files
committed
debugging failing test
1 parent 7378a92 commit 8b8730d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

spec/http_util.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ def initialize(enable_compression: false)
2424
rescue Errno::EADDRINUSE
2525
@port = StubHTTPServer.next_port
2626
retry
27+
rescue Errno::EACCES => e
28+
warn "DIAGNOSTIC: Failed to bind to 127.0.0.1:#{@port}"
29+
warn "DIAGNOSTIC: Platform: #{RUBY_PLATFORM}"
30+
warn "DIAGNOSTIC: Ruby version: #{RUBY_VERSION}"
31+
warn "DIAGNOSTIC: This likely indicates Windows Firewall, antivirus, or permission issues"
32+
raise "Port binding failed - likely Windows Firewall/AV issue: #{e.message}"
2733
end
2834
@requests = []
2935
@requests_queue = Queue.new
@@ -36,7 +42,12 @@ def self.next_port
3642
end
3743

3844
def create_server(port, base_opts)
39-
WEBrick::HTTPServer.new(base_opts)
45+
# Use port 0 to let the OS assign an available port (more reliable on Windows)
46+
base_opts[:Port] = 0
47+
server = WEBrick::HTTPServer.new(base_opts)
48+
# Update @port with the actual port assigned by the OS
49+
@port = server.config[:Port]
50+
server
4051
end
4152

4253
def start

0 commit comments

Comments
 (0)