Skip to content

[🐛 Bug]: Selector manager threads are leaking when a proxy is passed and remoteWebDriver instantiation fails #13622

@Camill06

Description

@Camill06

What happened?

Since I'm using the JDK http client, i'm facing an issue with selectorManager threads that are hanging forever and do not finish. After several calls, I can notice that the number of hanging threads are increasing and the Java garbage collector does not delete them.
This issue is only happening when those two conditions are reunited:

  • A proxy is passed to the client config
  • The remoteWebDriver instantiation fails. Whatever the reason of the failure : timeout, proxy not reachable, url not reachable, wrong driver version....

If the driver instantiation succeeds or if no proxy is passed, the selectorManager threads are not stuck and will be able to end.

How can we reproduce the issue?

// dummy proxy to have a failing instantiation      
Proxy myProxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("localhost", 1234));

        ClientConfig config = null;
        URL myUrl = null;
        try {
            myUrl = new URL("http://myseleniumserver:1234");
        } catch (MalformedURLException e) {
            LOG.error("Remote URL is not correct", e);
        }
        config = ClientConfig.defaultConfig().baseUrl(myUrl).proxy(myProxy);

        HttpCommandExecutor myExecutor = null;
        Factory factory = Factory.createDefault();
        myExecutor = new HttpCommandExecutor(new HashMap<String, CommandInfo>(), config, factory);

        ChromeOptions copt = new ChromeOptions();
        try {
            WebDriver driver = new RemoteWebDriver(myExecutor, copt);
        } catch (WebDriverException e) {
            LOG.error("Driver could not be created", e);
        }

Relevant log output

NA

Operating System

macOS Sonoma 14.3.1

Selenium version

Java 4.18.1

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

Chrome 122

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

Chromedriver 122

Are you using Selenium Grid?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-javaJava BindingsI-defectSomething is not working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions