thebrowsercompany / swift-webdriver

A Swift library for communicating with WebDriver (Appium/WinAppDriver) endpoints
BSD 3-Clause "New" or "Revised" License
105 stars 3 forks source link

Timeout if the WebDriver HTTP endpoint is unreachable #40

Open tristanlabelle opened 1 year ago

tristanlabelle commented 1 year ago

Currently it seems like trying to send a request to a non-existing webdriver endpoint URL gets stuck forever. This is a problem now that tests require a webdriver to be started on a certain port, which can be easily forgotten.

tristanlabelle commented 1 year ago

The below neither prints "Callback" nor "Done waiting". It crashes (ud2) somewhere in dispatch beforehand.


var request = URLRequest.init(url: URL(string: "https://127.0.0.9")!)
request.timeoutInterval = 0.1

print("\(Date()): Requesting...")
URLSession.shared.dataTask(with: request) { _, _, _ in print("Callback") }.resume()
print("\(Date()): Waiting...")
Thread.sleep(forTimeInterval: 5)
print("\(Date()): Done waiting.")