Skip to content

Commit bcd1479

Browse files
committed
Fix random Broken pipe error in TestOpenURI#test_read_timeout
The server thread writes the HTTP response while the client has a 0.1s read_timeout. On slow CI (especially Windows), the client can time out and close the socket before the server finishes writing headers or the response body, causing Errno::EPIPE in the server thread. Since the broken pipe is expected when the client times out, rescue it along with ECONNRESET and ECONNABORTED. This attempts to mitigate random CI failures like: https://github.com/ruby/ruby/actions/runs/23921136139/job/69767484567?pr=16648 1) Error: TestOpenURI#test_read_timeout: Test::Unit::ProxyError: Broken pipe D:/a/ruby/ruby/src/test/open-uri/test_open-uri.rb:80:in 'IO#write' D:/a/ruby/ruby/src/test/open-uri/test_open-uri.rb:80:in 'IO#print' D:/a/ruby/ruby/src/test/open-uri/test_open-uri.rb:80:in 'block (2 levels) in TestOpenURI#test_read_timeout'
1 parent 409b88d commit bcd1479

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

test/open-uri/test_open-uri.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ def test_read_timeout
8080
sock.print "Content-Length: 4\r\n\r\n"
8181
sleep 1
8282
sock.print "ab\r\n"
83+
rescue Errno::EPIPE, Errno::ECONNRESET, Errno::ECONNABORTED
84+
# expected when client times out and closes the connection
8385
ensure
8486
sock.close
8587
end

0 commit comments

Comments
 (0)