DEV: puts debugging information when CI encounters resolution errors (#27300)

We have been seeing flaky socket resolution errors on CI and need more
debugging information to figure out why
This commit is contained in:
Alan Guo Xiang Tan 2024-06-03 10:26:02 +08:00 committed by GitHub
parent 50e573e797
commit c408b53689
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -518,6 +518,21 @@ RSpec.configure do |config|
sleep 0.01 while !mutex.synchronize { is_waiting }
end
end
config.around do |example|
example.run
if example.exception.is_a?(Socket::ResolutionError)
info = Socket.getaddrinfo("localhost", nil)
etc_hosts = `cat /etc/hosts`
puts <<~MSG
Failed to resolve localhost, available addresses: #{info}
/etc/hosts:
#{etc_hosts}
MSG
end
end
end
if ENV["DISCOURSE_RSPEC_PROFILE_EACH_EXAMPLE"]