SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
30.13k stars 8.1k forks source link

[🐛 Bug]: Selenium Java Versions 4.22.0 throws RejectedExecutionException warning when running on Selenium Grid #14280

Open kherath17 opened 1 month ago

kherath17 commented 1 month ago

What happened?

I have customized the RemoteWebDriver through builder(); to add a readTimeOut and recently upgrade to latest version 4.22.0 and now when I run on grid the tests successfully gets executed but below exception is thrown as a warning

WARNING: java.util.concurrent.RejectedExecutionException: Task jdk.internal.net.http.common.SequentialScheduler$SchedulableTask@471be3ad rejected from java.util.concurrent.ThreadPoolExecutor@3b9b1652[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 5] java.io.IOException: java.util.concurrent.RejectedExecutionException: Task jdk.internal.net.http.common.SequentialScheduler$SchedulableTask@471be3ad rejected from java.util.concurrent.ThreadPoolExecutor@3b9b1652[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 5]

How can we reproduce the issue?

Setup like below and run on selenium grid

 @Test
    public void sample_test2() throws MalformedURLException {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setBrowserName("chrome");
        RemoteWebDriver remoteWebDriver = (RemoteWebDriver) RemoteWebDriver.builder().address("gridURL").oneOf(capabilities, new Capabilities[0]).config(ClientConfig.defaultConfig().readTimeout(Duration.ofSeconds(360))).build();
        remoteWebDriver.get("https://www.google.com");
        remoteWebDriver.quit();
    }

Relevant log output

Jul 19, 2024 3:19:32 PM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
WARNING: Unable to find an exact match for CDP version 126, returning the closest version; found: 125; Please update to a Selenium version that supports CDP version 126
Jul 19, 2024 3:19:37 PM org.openqa.selenium.remote.http.WebSocket$Listener onError
WARNING: java.util.concurrent.RejectedExecutionException: Task jdk.internal.net.http.common.SequentialScheduler$SchedulableTask@471be3ad rejected from java.util.concurrent.ThreadPoolExecutor@3b9b1652[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 5]
java.io.IOException: java.util.concurrent.RejectedExecutionException: Task jdk.internal.net.http.common.SequentialScheduler$SchedulableTask@471be3ad rejected from java.util.concurrent.ThreadPoolExecutor@3b9b1652[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 5]
    at java.net.http/jdk.internal.net.http.common.Utils.getIOException(Utils.java:303)
    at java.net.http/jdk.internal.net.http.RawChannelTube.read(RawChannelTube.java:306)
    at java.net.http/jdk.internal.net.http.websocket.TransportImpl$ReceiveTask.run(TransportImpl.java:697)
    at java.net.http/jdk.internal.net.http.common.SequentialScheduler$CompleteRestartableTask.run(SequentialScheduler.java:147)
    at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:198)
    at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:271)
    at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:224)
    at java.net.http/jdk.internal.net.http.websocket.TransportImpl$ReadEvent.handle(TransportImpl.java:762)
    at java.net.http/jdk.internal.net.http.RawChannelTube$ReadSubscriber.checkEvents(RawChannelTube.java:174)
    at java.net.http/jdk.internal.net.http.RawChannelTube$ReadSubscriber.onError(RawChannelTube.java:212)
    at java.net.http/jdk.internal.net.http.common.SSLTube$DelegateWrapper.onError(SSLTube.java:249)
    at java.net.http/jdk.internal.net.http.common.SSLTube$SSLSubscriberWrapper.complete(SSLTube.java:433)
    at java.net.http/jdk.internal.net.http.common.SSLTube$SSLSubscriberWrapper.onErrorImpl(SSLTube.java:503)
    at java.net.http/jdk.internal.net.http.common.SSLTube$SSLSubscriberWrapper.onError(SSLTube.java:517)
    at java.net.http/jdk.internal.net.http.common.SubscriberWrapper$DownstreamPusher.run1(SubscriberWrapper.java:296)
    at java.net.http/jdk.internal.net.http.common.SubscriberWrapper$DownstreamPusher.run(SubscriberWrapper.java:261)
    at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SynchronizedRestartableTask.run(SequentialScheduler.java:175)
    at java.net.http/jdk.internal.net.http.common.SequentialScheduler$CompleteRestartableTask.run(SequentialScheduler.java:147)
    at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:198)
    at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:271)
    at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:224)
    at java.net.http/jdk.internal.net.http.common.SubscriberWrapper.errorCommon(SubscriberWrapper.java:390)
    at java.net.http/jdk.internal.net.http.common.SubscriberWrapper.incomingCaller(SubscriberWrapper.java:409)
    at java.net.http/jdk.internal.net.http.common.SubscriberWrapper.onNext(SubscriberWrapper.java:358)
    at java.net.http/jdk.internal.net.http.common.SubscriberWrapper.onNext(SubscriberWrapper.java:59)
    at java.net.http/jdk.internal.net.http.SocketTube$InternalReadPublisher$InternalReadSubscription.read(SocketTube.java:844)
    at java.net.http/jdk.internal.net.http.SocketTube$SocketFlowTask.run(SocketTube.java:175)
    at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:198)
    at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:271)
    at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:224)
    at java.net.http/jdk.internal.net.http.SocketTube$InternalReadPublisher$InternalReadSubscription.signalReadable(SocketTube.java:763)
    at java.net.http/jdk.internal.net.http.SocketTube$InternalReadPublisher$ReadEvent.signalEvent(SocketTube.java:941)
    at java.net.http/jdk.internal.net.http.SocketTube$SocketFlowEvent.handle(SocketTube.java:245)
    at java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.handleEvent(HttpClientImpl.java:957)
    at java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.lambda$run$3(HttpClientImpl.java:912)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
    at java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.run(HttpClientImpl.java:912)
Caused by: java.util.concurrent.RejectedExecutionException: Task jdk.internal.net.http.common.SequentialScheduler$SchedulableTask@471be3ad rejected from java.util.concurrent.ThreadPoolExecutor@3b9b1652[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 5]
    at java.base/java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2055)
    at java.base/java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:825)
    at java.base/java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1355)
    at java.net.http/jdk.internal.net.http.HttpClientImpl$DelegatingExecutor.execute(HttpClientImpl.java:151)
    at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:273)
    at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:242)
    at java.net.http/jdk.internal.net.http.common.SSLFlowDelegate$Reader.incoming(SSLFlowDelegate.java:298)
    at java.net.http/jdk.internal.net.http.common.SubscriberWrapper.incomingCaller(SubscriberWrapper.java:407)
    ... 14 more

Operating System

Windows 11

Selenium version

4.22.0

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

Chrome

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

126.0.6478.127

Are you using Selenium Grid?

4.18.1

github-actions[bot] commented 1 month ago

@kherath17, 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 commented 1 month ago

Hey! Is this happening in the latest Selenium version 4.23.0 too?

joerg1985 commented 1 month ago

@pujagani i think i can fix this the next days, we are sending a close message and do not wait for the close message from the other end before shutting down the executor. This will lead to a incomming message in the closed state of the executor.

This should be not a big issue, but it does log a warning that can be avoided easily.

joerg1985 commented 1 month ago

@kherath17 this should be fixed with the next release. You could try to upgrade to the next nightly build to confirm this.

pujagani commented 1 month ago

Thank you @joerg1985!

kherath17 commented 1 month ago

Thank You @joerg1985 for promptly looking into this, will confirm with the next release made

sadiqkassamali commented 4 weeks ago

Ty for the fix :)