From d38ce7065fb816b789374c2d9ac5a61913dc7b45 Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Thu, 31 Aug 2023 01:34:26 +0300 Subject: [PATCH] [dotnet] Avoid potential deadlock when starting new dev tools session (#12592) Avoid potential deadlock when starting new dev tools session --- dotnet/src/webdriver/Chromium/ChromiumDriver.cs | 3 ++- dotnet/src/webdriver/Firefox/FirefoxDriver.cs | 3 ++- dotnet/src/webdriver/Remote/RemoteWebDriver.cs | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/dotnet/src/webdriver/Chromium/ChromiumDriver.cs b/dotnet/src/webdriver/Chromium/ChromiumDriver.cs index ee9e4fd3088ed..a27d4fa9eb25b 100644 --- a/dotnet/src/webdriver/Chromium/ChromiumDriver.cs +++ b/dotnet/src/webdriver/Chromium/ChromiumDriver.cs @@ -20,6 +20,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; +using System.Threading.Tasks; using OpenQA.Selenium.DevTools; using OpenQA.Selenium.Remote; @@ -303,7 +304,7 @@ public DevToolsSession GetDevToolsSession(int devToolsProtocolVersion) try { DevToolsSession session = new DevToolsSession(debuggerAddress); - session.StartSession(devToolsProtocolVersion).ConfigureAwait(false).GetAwaiter().GetResult(); + Task.Run(async () => await session.StartSession(devToolsProtocolVersion)).GetAwaiter().GetResult(); this.devToolsSession = session; } catch (Exception e) diff --git a/dotnet/src/webdriver/Firefox/FirefoxDriver.cs b/dotnet/src/webdriver/Firefox/FirefoxDriver.cs index 92d06b59469c4..27312276dafe9 100644 --- a/dotnet/src/webdriver/Firefox/FirefoxDriver.cs +++ b/dotnet/src/webdriver/Firefox/FirefoxDriver.cs @@ -22,6 +22,7 @@ using System.Globalization; using System.IO; using System.IO.Compression; +using System.Threading.Tasks; using OpenQA.Selenium.DevTools; using OpenQA.Selenium.Remote; @@ -395,7 +396,7 @@ public DevToolsSession GetDevToolsSession(int devToolsProtocolVersion) try { DevToolsSession session = new DevToolsSession(debuggerAddress); - session.StartSession(devToolsProtocolVersion).ConfigureAwait(false).GetAwaiter().GetResult(); + Task.Run(async () => await session.StartSession(devToolsProtocolVersion)).GetAwaiter().GetResult(); this.devToolsSession = session; } catch (Exception e) diff --git a/dotnet/src/webdriver/Remote/RemoteWebDriver.cs b/dotnet/src/webdriver/Remote/RemoteWebDriver.cs index 4eb8c228d32b9..8205ff4ea14fc 100644 --- a/dotnet/src/webdriver/Remote/RemoteWebDriver.cs +++ b/dotnet/src/webdriver/Remote/RemoteWebDriver.cs @@ -19,6 +19,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Threading.Tasks; using OpenQA.Selenium.DevTools; using OpenQA.Selenium.Internal; @@ -455,7 +456,7 @@ public DevToolsSession GetDevToolsSession(int protocolVersion) try { DevToolsSession session = new DevToolsSession(debuggerAddress); - session.StartSession(devToolsProtocolVersion).ConfigureAwait(false).GetAwaiter().GetResult(); + Task.Run(async () => await session.StartSession(devToolsProtocolVersion)).GetAwaiter().GetResult(); this.devToolsSession = session; } catch (Exception e)