Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐛 Bug]: CDP NetworkInterceptor warning when reading request body/contents #15013

Open
MichailiK opened this issue Jan 2, 2025 · 1 comment

Comments

@MichailiK
Copy link

MichailiK commented Jan 2, 2025

What happened?

Whenever the request contents of a request gets read, a warning message gets logged, which can be pretty huge, as it dumps the entire request, including headers & contents. For my usage, this doesn't seem to be causing any actual issues though.

How can we reproduce the issue?

WebDriver driver = new ChromeDriver();

CompletableFuture<String> interceptorFuture = new CompletableFuture<>();

NetworkInterceptor interceptor = new NetworkInterceptor(driver,
  (Filter) next -> req -> {
    HttpResponse res = next.execute(req);

    if (req.getMethod() != HttpMethod.POST || !req.getUri().contains("/somewhere"))
      return res;

    // Read request contents
    String body = Contents.string(req);

    // Extract something from the request contents, for example a guess:
    Matcher m = Pattern.compile("Guess: (.+)").matcher(body);
    if (!m.matches()) {
      interceptorFuture.complete(null);
      return res;
    }

    interceptorFuture.complete(m.group(1));
    return res;
});

driver.get("https://example.com");

try {
  // Wait for the network interceptor to extract the guess
  String guess = interceptorFuture.get(20, TimeUnit.SECONDS);
  System.out.println("The provided guess is: " + guess);
} catch (TimeoutException e) {
  System.out.println("Timed out waiting for request");
} finally {
  interceptor.close();
  driver.quit();
}

Relevant log output

Request headers & contents are replaced with ellipsis for brevity:

Jan 02, 2025 9:57:22 PM org.openqa.selenium.devtools.v131.v131Network createSeMessages
WARNING: Unable to get body for request id interception-job-11.0
Jan 02, 2025 9:57:22 PM org.openqa.selenium.devtools.Connection$Listener lambda$onText$0
WARNING: Unable to process: {"method":"Fetch.requestPaused","params":{"requestId":"interception-job-28.0","request":{"url":"https://example.com/somewhere","method":"POST","headers":{...},"postData":...,"hasPostData":true,"postDataEntries":[{"bytes":"..."}],"initialPriority":"High","referrerPolicy":"strict-origin-when-cross-origin"},"frameId":"69BEE165D3B87248237DB40E317194A0","resourceType":"XHR"},"sessionId":"A785B230870B433A977038CF6CF7CD23"}
org.openqa.selenium.devtools.DevToolsException: {"id":96,"error":{"code":-32000,"message":"Fetch domain is not enabled"},"sessionId":"A785B230870B433A977038CF6CF7CD23"}
Build info: version: '4.27.0', revision: 'd6e718d134'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.6.52', java.version: '21.0.4'
Driver info: driver.version: unknown
        at org.openqa.selenium.devtools.Connection.sendAndWait(Connection.java:195)
        at org.openqa.selenium.devtools.DevTools.send(DevTools.java:90)
        at org.openqa.selenium.devtools.idealized.Network.lambda$prepareToInterceptTraffic$5(Network.java:273)
        at org.openqa.selenium.devtools.DevTools.lambda$addListener$0(DevTools.java:104)
        at org.openqa.selenium.devtools.Connection.lambda$handle$5(Connection.java:348)
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
        at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
        at java.base/java.util.stream.ReferencePipeline$15$1.accept(ReferencePipeline.java:541)
        at java.base/java.util.HashMap$EntrySpliterator.forEachRemaining(HashMap.java:1858)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
        at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
        at org.openqa.selenium.devtools.Connection.handle(Connection.java:311)
        at org.openqa.selenium.devtools.Connection$Listener.lambda$onText$0(Connection.java:239)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
        at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: org.openqa.selenium.WebDriverException: {"id":96,"error":{"code":-32000,"message":"Fetch domain is not enabled"},"sessionId":"A785B230870B433A977038CF6CF7CD23"}
Build info: version: '4.27.0', revision: 'd6e718d134'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.6.52', java.version: '21.0.4'
Driver info: driver.version: unknown
        at org.openqa.selenium.devtools.Connection.handle(Connection.java:275)
        ... 4 more

Exception in thread "CDP Connection" org.openqa.selenium.devtools.DevToolsException: {"id":96,"error":{"code":-32000,"message":"Fetch domain is not enabled"},"sessionId":"A785B230870B433A977038CF6CF7CD23"}
Build info: version: '4.27.0', revision: 'd6e718d134'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.6.52', java.version: '21.0.4'
Driver info: driver.version: unknown
        at org.openqa.selenium.devtools.Connection$Listener.lambda$onText$0(Connection.java:242)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
        at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: org.openqa.selenium.devtools.DevToolsException: {"id":96,"error":{"code":-32000,"message":"Fetch domain is not enabled"},"sessionId":"A785B230870B433A977038CF6CF7CD23"}
Build info: version: '4.27.0', revision: 'd6e718d134'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.6.52', java.version: '21.0.4'
Driver info: driver.version: unknown
        at org.openqa.selenium.devtools.Connection.sendAndWait(Connection.java:195)
        at org.openqa.selenium.devtools.DevTools.send(DevTools.java:90)
        at org.openqa.selenium.devtools.idealized.Network.lambda$prepareToInterceptTraffic$5(Network.java:273)
        at org.openqa.selenium.devtools.DevTools.lambda$addListener$0(DevTools.java:104)
        at org.openqa.selenium.devtools.Connection.lambda$handle$5(Connection.java:348)
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
        at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
        at java.base/java.util.stream.ReferencePipeline$15$1.accept(ReferencePipeline.java:541)
        at java.base/java.util.HashMap$EntrySpliterator.forEachRemaining(HashMap.java:1858)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
        at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
        at org.openqa.selenium.devtools.Connection.handle(Connection.java:311)
        at org.openqa.selenium.devtools.Connection$Listener.lambda$onText$0(Connection.java:239)
        ... 3 more
Caused by: org.openqa.selenium.WebDriverException: {"id":96,"error":{"code":-32000,"message":"Fetch domain is not enabled"},"sessionId":"A785B230870B433A977038CF6CF7CD23"}
Build info: version: '4.27.0', revision: 'd6e718d134'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.6.52', java.version: '21.0.4'
Driver info: driver.version: unknown
        at org.openqa.selenium.devtools.Connection.handle(Connection.java:275)
        ... 4 more

Operating System

NixOS 24.11

Selenium version

Java 4.27.0

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

Chromium 131.0.6778.204

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

ChromeDriver 131.0.6778.204

Are you using Selenium Grid?

No response

Copy link

github-actions bot commented Jan 2, 2025

@MichailiK, 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant