Skip to content

[🐛 Bug]: When encounter an exception in RemoteWebDriverBuilder.build(), the underlaying HttpClient resources are not released #15710

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

Open
jacklee1983 opened this issue May 7, 2025 · 6 comments
Labels
A-needs-triaging A Selenium member will evaluate this soon! C-java Java Bindings I-defect Something is not working as intended OS-linux R-help wanted Issues looking for contributions

Comments

@jacklee1983
Copy link

jacklee1983 commented May 7, 2025

Description

var webDriver = RemoteWebDriver.builder().address(REMOTE_URL).build()
In the above code when there is an exception in the build() method, no webDriver instance returned and I cannot release the underlaying HttpClient resources. Could we consider releasing the HttpClient resources inside the build() before throwing an exception?
The exception example :

org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: java.io.IOException: Proxy-Authenticate header missing for response code 407
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:114)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:75)
at org.openqa.selenium.remote.RemoteWebDriverBuilder.getRemoteDriver(RemoteWebDriverBuilder.java:394)
at org.openqa.selenium.remote.RemoteWebDriverBuilder.build(RemoteWebDriverBuilder.java:366)

Reproducible Code

var webDriver = RemoteWebDriver.builder().address(REMOTE_URL).build()

Debugging Logs

org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: java.io.IOException: Proxy-Authenticate header missing for response code 407 
	at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:114)
	at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:75)
	at org.openqa.selenium.remote.RemoteWebDriverBuilder.getRemoteDriver(RemoteWebDriverBuilder.java:394)
	at org.openqa.selenium.remote.RemoteWebDriverBuilder.build(RemoteWebDriverBuilder.java:366)
@jacklee1983 jacklee1983 added I-defect Something is not working as intended A-needs-triaging A Selenium member will evaluate this soon! labels May 7, 2025
@selenium-ci
Copy link
Member

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

Selenium Triage Team: remember to follow the Triage Guide

@github-actions github-actions bot added C-java Java Bindings OS-linux labels May 7, 2025
Copy link

github-actions bot commented May 7, 2025

⚠️ You reported using Selenium version 4.24.0, but the latest release is 4.32.

Please verify that this issue still occurs with the latest version. If it no longer applies, you can close this issue or update your comment.

This issue will be marked "awaiting answer" and may be closed automatically if no response is received.

@github-actions github-actions bot added J-awaiting answer Question asked of user; a reply moves it to triage again and removed A-needs-triaging A Selenium member will evaluate this soon! labels May 7, 2025
@jacklee1983
Copy link
Author

In the newest 4.32 version. the RemoteWebDriverBuilder.getRemoteDriver() method still doesn't release the HttpClient resources before throwing an exception.

@github-actions github-actions bot added A-needs-triaging A Selenium member will evaluate this soon! and removed J-awaiting answer Question asked of user; a reply moves it to triage again labels May 7, 2025
@diemol
Copy link
Member

diemol commented May 7, 2025

Would you like to send a PR to improve this?

@diemol diemol added the R-help wanted Issues looking for contributions label May 7, 2025
@selenium-ci
Copy link
Member

This issue is looking for contributors.

Please comment below or reach out to us through our IRC/Slack/Matrix channels if you are interested.

@jacklee1983
Copy link
Author

Let me look into the source code first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-needs-triaging A Selenium member will evaluate this soon! C-java Java Bindings I-defect Something is not working as intended OS-linux R-help wanted Issues looking for contributions
Projects
None yet
Development

No branches or pull requests

3 participants