Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐛 Bug]: BiDi Connection is established on driver.close / driver.quit #13316

Closed
joerg1985 opened this issue Dec 15, 2023 · 3 comments · Fixed by #13333
Closed

[🐛 Bug]: BiDi Connection is established on driver.close / driver.quit #13316

joerg1985 opened this issue Dec 15, 2023 · 3 comments · Fixed by #13333

Comments

@joerg1985
Copy link
Member

What happened?

Start a BiDi enabled session, but do not call driver.getBiDi(), this will let the driver initialize the connection on driver.close() and driver.quit().

Both calls will run into a TimeoutException after ~ 30s, this makes the shutdown of such a driver very slow and exceptions need to be handled.

How can we reproduce the issue?

var options = new ChromeOptions();        
options.setCapability("webSocketUrl", true);
Augmenter augmenter = new Augmenter();
WebDriver driver = augmenter.augment(new RemoteWebDriver(uri, options));

try {
    DevTools devTools = ((HasDevTools) driver).getDevTools();
    devTools.createSession();

    driver.close();
} catch (Exception e) {
    e.printStackTrace();
} finally {
    try {
        driver.quit();
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

Relevant log output

org.openqa.selenium.TimeoutException: java.util.concurrent.TimeoutException
Build info: version: '4.16.0', revision: '15400459dd*'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '21.0.1'
Driver info: driver.version: RemoteWebDriver
	at org.openqa.selenium.bidi.Connection.sendAndWait(Connection.java:172)
	at org.openqa.selenium.bidi.BiDi.send(BiDi.java:54)
	at org.openqa.selenium.bidi.BiDi.<init>(BiDi.java:37)
	at org.openqa.selenium.bidi.BiDiProvider.lambda$getImplementation$2(BiDiProvider.java:55)
	at org.openqa.selenium.remote.RemoteWebDriver$ByteBuddy$3k6C8irl.maybeGetBiDi(Unknown Source)
	at org.openqa.selenium.remote.RemoteWebDriver.quit(RemoteWebDriver.java:435)
	at some.issues.Main.lambda$main$0(Main.java:39)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.util.concurrent.TimeoutException
	at java.base/java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1960)
	at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2095)
	at org.openqa.selenium.bidi.Connection.sendAndWait(Connection.java:161)
	... 11 more

Operating System

win 10 x64

Selenium version

4.16.1

What are the browser(s) and version(s) where you see this issue?

chrome 120

What are the browser driver(s) and version(s) where you see this issue?

chromedriver 120

Are you using Selenium Grid?

4.16.1

Copy link

@joerg1985, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@pujagani
Copy link
Contributor

The error above only happens if the WebDriver has enabled BiDi and it has only top-level browsing context and the close() closes it. That means the underlying, session is closed too and the BiDi session needs to be closed. So if the quit() is called after it, it also tries to close the BiDi session which is already and hence the time out happens. I am looking into fixing this.

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Jan 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants