selenium: [πŸ› Bug]: .NET - Fetch.getResponseBody error when Network monitoring enabled

What happened?

We use Network monitoring to log requests and responses for failed tests.

            var network = _driver.Manage().Network;
            await network.StartMonitoring();
            network.NetworkRequestSent += NetworkRequestSent;
            network.NetworkResponseReceived += NetworkResponseReceived;

Unfortunately, sometimes we receive the following errors:

System.InvalidOperationException: A command response was not received: Fetch.getResponseBody

It happens it random places, and we cannot reproduce that consistently. Even worse that it makes the whole test run crash.

How can we reproduce the issue?

Unfortunately, I don’t know how to reproduce this issue consistently. Sometimes it happens, sometimes it doesn’t. I’ll update this issue if I am able to find a repro case

Relevant log output

The active test run was aborted. Reason: Test host process crashed :

Unhandled exception. System.InvalidOperationException: A command response was not received: Fetch.getResponseBody
   at OpenQA.Selenium.DevTools.DevToolsSession.SendCommand(String commandName, JToken commandParameters, CancellationToken cancellationToken, Nullable`1 millisecondsTimeout, Boolean throwExceptionIfResponseNotReceived)
   at OpenQA.Selenium.DevTools.DevToolsSession.SendCommand[TCommand,TCommandResponse](TCommand command, CancellationToken cancellationToken, Nullable`1 millisecondsTimeout, Boolean throwExceptionIfResponseNotReceived)
   at OpenQA.Selenium.DevTools.V96.Fetch.FetchAdapter.GetResponseBody(GetResponseBodyCommandSettings command, CancellationToken cancellationToken, Nullable`1 millisecondsTimeout, Boolean throwExceptionIfResponseNotReceived)
   at OpenQA.Selenium.DevTools.V96.V96Network.AddResponseBody(HttpResponseData responseData)
   at OpenQA.Selenium.NetworkManager.OnResponsePaused(Object sender, ResponsePausedEventArgs e)
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__139_1(Object state)
   at System.Threading.QueueUserWorkItemCallback.<>c.<.cctor>b__6_0(QueueUserWorkItemCallback quwi)
   at System.Threading.ExecutionContext.RunForThreadPoolUnsafe[TState](ExecutionContext executionContext, Action`1 callback, TState& state)
   at System.Threading.QueueUserWorkItemCallback.Execute()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()

Operating System

Windows 10, Linux

Selenium version

.NET 4.1.0

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

Chrome 97

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

ChromeDriver 97.0.4692.7100

Are you using Selenium Grid?

No

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 9
  • Comments: 15 (3 by maintainers)

Most upvoted comments

Intrusion

I have changed Selenium to Playwright and everything works well.

The current DevTools implementation in .NET is not ideal, and we are looking for people who are interested in making it better.