selenium icon indicating copy to clipboard operation
selenium copied to clipboard

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

Open jacklee1983 opened this issue 7 months ago • 6 comments

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 avatar May 07 '25 09:05 jacklee1983

@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

selenium-ci avatar May 07 '25 09:05 selenium-ci

⚠️ 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[bot] avatar May 07 '25 09:05 github-actions[bot]

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

jacklee1983 avatar May 07 '25 10:05 jacklee1983

Would you like to send a PR to improve this?

diemol avatar May 07 '25 10:05 diemol

This issue is looking for contributors.

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

selenium-ci avatar May 07 '25 10:05 selenium-ci

Let me look into the source code first.

jacklee1983 avatar May 07 '25 13:05 jacklee1983

@jacklee1983 should be fixed with c82f92ea2fbfe3e390158d53fcb318da097f0518 could you test it with a nightly build?

joerg1985 avatar Jul 16 '25 19:07 joerg1985

@joerg1985 Can you create Pull Requests for changes instead of pushing to trunk? It makes reverting and keeping track of changes much easier.

cgoldberg avatar Jul 16 '25 19:07 cgoldberg

@cgoldberg yes, will do so in future. in the past i only did PRs for bigger things.

joerg1985 avatar Jul 16 '25 19:07 joerg1985

@joerg1985 thanks.. it's best to do so for all changes, even if it's a small change and you approve it yourself.

cgoldberg avatar Jul 16 '25 19:07 cgoldberg

This issue was closed because we did not receive any additional information after 14 days.

github-actions[bot] avatar Aug 28 '25 20:08 github-actions[bot]

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

github-actions[bot] avatar Sep 27 '25 22:09 github-actions[bot]