Created
August 10, 2016 01:05
-
-
Save junosuarez/ecc845b10adf68faf26ff3c9edd3f1ba to your computer and use it in GitHub Desktop.
If you suddenly get a lot of cryptic errors in travis like `Errno::EINVAL: Errno::EINVAL: Invalid argument - bind(2) for "fe80::4001:aff:::fff" port 9515` then maybe this will save you 5 hours
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Monkeypatch Selenium Webdriver to work on Travis IPv6 infrastructure | |
module Selenium | |
module WebDriver | |
class PortProber | |
IGNORED_ERRORS = [Errno::EADDRNOTAVAIL, Errno::EINVAL, Errno::EACCES].freeze | |
IGNORED_ERRORS << Errno::EBADF if Platform.cygwin? | |
def self.free?(port) | |
interfaces = Socket.getaddrinfo('localhost', 8080).map { |e| e[3] } | |
interfaces.each do |host| | |
begin | |
TCPServer.new(host, port).close | |
rescue *IGNORED_ERRORS => ex | |
$stderr.puts "port prober could not bind to #{host}:#{port} (#{ex.message})" if $DEBUG | |
# ignored - some machines appear unable to bind to some of their interfaces | |
end | |
end | |
true | |
rescue | |
false | |
end | |
end # PortProber | |
end # WebDriver | |
end # Selenium |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment