Closed
Description
What happened?
Selenium WebDriver freezes on continueRequest command after intercepting in phase BEFORE_REQUEST_SENT and consequently fails with a timeout.
How can we reproduce the issue?
package com.example.selenium;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.bidi.module.Network;
import org.openqa.selenium.bidi.network.AddInterceptParameters;
import org.openqa.selenium.bidi.network.ContinueRequestParameters;
import org.openqa.selenium.bidi.network.InterceptPhase;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.Augmenter;
import org.openqa.selenium.remote.RemoteWebDriver;
public class Test {
public static void main(String[] args) throws MalformedURLException {
ChromeOptions options = new ChromeOptions();
options.enableBiDi();
RemoteWebDriver webDriver =
new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), options);
WebDriver augmented = new Augmenter().augment(webDriver);
try (Network network = new Network(augmented)) {
network.addIntercept(new AddInterceptParameters(InterceptPhase.BEFORE_REQUEST_SENT));
network.onBeforeRequestSent(
beforeRequestSent ->
network.continueRequest(
new ContinueRequestParameters(beforeRequestSent.getRequest().getRequestId())));
augmented.get("https://google.com");
augmented.close();
}
}
}
Relevant log output
2025-04-02T08:08:35.102+02:00 INFO 30496 --- [ task-3] o.o.s.b.Connection : -> {
"params": {
"phases": [
"beforeRequestSent"
]
},
"method": "network.addIntercept",
"id": 1
}
2025-04-02T08:08:35.124+02:00 INFO 30496 --- [BiDi Connection] o.o.s.b.Connection : <- {"id":1,"result":{"intercept":"7771b1c4-dc9b-4bef-973e-1d114fa810b2"},"type":"success"}
2025-04-02T08:08:35.128+02:00 INFO 30496 --- [ task-3] o.o.s.b.Connection : -> {
"params": {
"events": [
"network.beforeRequestSent"
]
},
"method": "session.subscribe",
"id": 2
}
2025-04-02T08:08:35.138+02:00 INFO 30496 --- [BiDi Connection] o.o.s.b.Connection : <- {"id":2,"result":{"subscription":"b34bab86-6f13-45c0-99e1-90d3a19bda03"},"type":"success"}
2025-04-02T08:08:35.204+02:00 INFO 30496 --- [BiDi Connection] o.o.s.b.Connection : <- {"method":"network.beforeRequestSent","params":{"context":"FE2F757DE077C6E1F559B9D1E4D0128A","initiator":{"type":"other"},"intercepts":["7771b1c4-dc9b-4bef-973e-1d114fa810b2"],"isBlocked":true,"navigation":"0ef892ed-b653-4fd1-bfc5-9c0274a124c1","redirectCount":0,"request":{"bodySize":0,"cookies":[],"destination":"","goog:resourceInitiator":{"type":"other"},"goog:resourceType":"Document","headers":[{"name":"Upgrade-Insecure-Requests","value":{"type":"string","value":"1"}},{"name":"User-Agent","value":{"type":"string","value":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36"}},{"name":"sec-ch-ua","value":{"type":"string","value":"\"Chromium\";v=\"134\", \"Not:A-Brand\";v=\"24\", \"Google Chrome\";v=\"134\""}},{"name":"sec-ch-ua-mobile","value":{"type":"string","value":"?0"}},{"name":"sec-ch-ua-platform","value":{"type":"string","value":"\"Linux\""}}],"headersSize":274,"initiatorType":null,"method":"GET","request":"59BCDDC33A17004D74489B8333C9467E","timings":{"connectEnd":0,"connectStart":0,"dnsEnd":0,"dnsStart":0,"fetchStart":0,"redirectEnd":0,"redirectStart":0,"requestStart":0,"requestTime":0,"responseEnd":0,"responseStart":0,"timeOrigin":1743574115184,"tlsStart":0},"url":"https://google.com/"},"timestamp":1743574115184},"type":"event"}
2025-04-02T08:08:35.211+02:00 INFO 30496 --- [BiDi Connection] o.o.s.b.Connection : Methodnetwork.beforeRequestSentcalled with1callbacks available
2025-04-02T08:08:35.213+02:00 INFO 30496 --- [BiDi Connection] o.o.s.b.Connection : Matching network.beforeRequestSent with network.beforeRequestSent
2025-04-02T08:08:35.258+02:00 INFO 30496 --- [BiDi Connection] o.o.s.b.Connection : Calling callback for network.beforeRequestSent using com.intrafind.webtopdf.selenium.SeleniumPdfPrinter$$Lambda$2556/0x0000000801969e88@74ab5e11 being passed org.openqa.selenium.bidi.network.BeforeRequestSent@90612a6
2025-04-02T08:08:36.131+02:00 INFO 30496 --- [BiDi Connection] o.o.s.b.Connection : -> {
"params": {
"request": "59BCDDC33A17004D74489B8333C9467E"
},
"method": "network.continueRequest",
"id": 3
}
Exception in thread "BiDi Connection" org.openqa.selenium.bidi.BiDiException: Unable to process: {"method":"network.beforeRequestSent","params":{"context":"FE2F757DE077C6E1F559B9D1E4D0128A","initiator":{"type":"other"},"intercepts":["7771b1c4-dc9b-4bef-973e-1d114fa810b2"],"isBlocked":true,"navigation":"0ef892ed-b653-4fd1-bfc5-9c0274a124c1","redirectCount":0,"request":{"bodySize":0,"cookies":[],"destination":"","goog:resourceInitiator":{"type":"other"},"goog:resourceType":"Document","headers":[{"name":"Upgrade-Insecure-Requests","value":{"type":"string","value":"1"}},{"name":"User-Agent","value":{"type":"string","value":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36"}},{"name":"sec-ch-ua","value":{"type":"string","value":"\"Chromium\";v=\"134\", \"Not:A-Brand\";v=\"24\", \"Google Chrome\";v=\"134\""}},{"name":"sec-ch-ua-mobile","value":{"type":"string","value":"?0"}},{"name":"sec-ch-ua-platform","value":{"type":"string","value":"\"Linux\""}}],"headersSize":274,"initiatorType":null,"method":"GET","request":"59BCDDC33A17004D74489B8333C9467E","timings":{"connectEnd":0,"connectStart":0,"dnsEnd":0,"dnsStart":0,"fetchStart":0,"redirectEnd":0,"redirectStart":0,"requestStart":0,"requestTime":0,"responseEnd":0,"responseStart":0,"timeOrigin":1743574115184,"tlsStart":0},"url":"https://google.com/"},"timestamp":1743574115184},"type":"event"}
at org.openqa.selenium.bidi.Connection$Listener.lambda$onText$0(Connection.java:279)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: org.openqa.selenium.TimeoutException: java.util.concurrent.TimeoutException
Build info: version: '4.30.0', revision: '509c7f17cc*'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '17'
Driver info: driver.version: unknown
at org.openqa.selenium.bidi.Connection.sendAndWait(Connection.java:180)
at org.openqa.selenium.bidi.BiDi.send(BiDi.java:51)
at org.openqa.selenium.bidi.module.Network.continueRequest(Network.java:131)
Operating System
Windows 10
Selenium version
Java 4.29.0
What are the browser(s) and version(s) where you see this issue?
Chrome 133
What are the browser driver(s) and version(s) where you see this issue?
RemoteWebDriver 4.29.0
Are you using Selenium Grid?
4.29.0