-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Description
What happened?
Summary
When a NetworkInterceptor
and related WebDriver are closed/quit, the "CDP Connection" thread may eventually throw a TimeoutException
.
This error occures a couple of seconds after the interceptor and driver have been closed/quit.
Here you can find a MCVE that is able to reproduce the error in at least 50% of the runs: https://github.com/tholewebgods/selenium-devtools-intercept-timeout-mcve (see the readme.md)
The code is reduced almost as much as possible for simplicity sake. The sleep is a replacement for a TestNG runner continuing to run further tests with new WebDriver sessions.
Guess
It looks like the CDP Connection thread is not informed of the interceptor shutdown and tries to handle communication that can no longer happen, finally running into a timeout.
Expectation
The CDP connection threads are
-
either terminated when the interceptor or related driver were quit or
-
brought into a state that allows the worker to either silently ignore timeouts or to log them as debug messages only to a proper logger. These exceptions should only be thrown by the thread runner if the interceptor is still open.
How can we reproduce the issue?
Here you can find a MCVE that is able to reproduce the error in at least 50% of the runs: https://github.com/tholewebgods/selenium-devtools-intercept-timeout-mcve (see the readme.md).
TL;DR:
1. Open an interceptor
2. Interact with the page
3. Close the interceptor
4. Close the driver
5. Wait > 10s
Relevant log output
org.openqa.selenium.TimeoutException: java.util.concurrent.TimeoutException
Build info: version: '4.1.3', revision: '7b1ebf28ef'
System info: host: 'h001287568', ip: '10.208.2.6', os.name: 'Linux', os.arch: 'amd64', os.version: '4.15.0-192-generic', java.version: '11.0.16'
Driver info: driver.version: unknown
at org.openqa.selenium.devtools.Connection.sendAndWait(Connection.java:161)
at org.openqa.selenium.devtools.DevTools.send(DevTools.java:70)
at org.openqa.selenium.devtools.idealized.Network.lambda$prepareToInterceptTraffic$4(Network.java:216)
at org.openqa.selenium.devtools.Connection.lambda$handle$6(Connection.java:288)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
at java.base/java.util.stream.ReferencePipeline$11$1.accept(ReferencePipeline.java:442)
at java.base/java.util.HashMap$KeySpliterator.forEachRemaining(HashMap.java:1621)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
at org.openqa.selenium.devtools.Connection.handle(Connection.java:257)
at org.openqa.selenium.devtools.Connection.access$200(Connection.java:58)
at org.openqa.selenium.devtools.Connection$Listener.lambda$onText$0(Connection.java:199)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.util.concurrent.TimeoutException
at java.base/java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1886)
at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2021)
at org.openqa.selenium.devtools.Connection.sendAndWait(Connection.java:150)
... 19 more
Operating System
Ubuntu
Selenium version
4.1.3
What are the browser(s) and version(s) where you see this issue?
Chrome 101 (Docker)
What are the browser driver(s) and version(s) where you see this issue?
101.0 (Docker)
Are you using Selenium Grid?
4.4.0-20220812 (Docker)