Skip to content

[wasm] Fix browser launch retry logic for chrome/edge#513

Merged
radical merged 1 commit intodotnet:mainfrom
radical:fix-chrome-retry
Mar 19, 2021
Merged

[wasm] Fix browser launch retry logic for chrome/edge#513
radical merged 1 commit intodotnet:mainfrom
radical:fix-chrome-retry

Conversation

@radical
Copy link
Copy Markdown
Member

@radical radical commented Mar 19, 2021

Sometimes starting the chromedriver can fail, and that can just be an
intermittent issue. For that reason, we have retry logic which is based
on check the WebDriverException's message for certain strings.

But the way the driver service is created changed in
7a34cdf, to use reflection, which meant
that the WebDriverException is thrown wrapped in a
TargetInvocationException, which then breaks our retry checks.

[02:56:47] crit: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
                  ---> OpenQA.Selenium.WebDriverException: Cannot start the driver service on http://localhost:39881/
                    at OpenQA.Selenium.DriverService.Start()
                    at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)
                    at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
                    at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
                    at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
                    at OpenQA.Selenium.Chromium.ChromiumDriver..ctor(ChromiumDriverService service, ChromiumOptions options, TimeSpan commandTimeout)
                    at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout)
                    --- End of inner exception stack trace ---
                    at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
                    at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
                    at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture)
                    at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
                    at Microsoft.DotNet.XHarness.CLI.Commands.Wasm.WasmTestBrowserCommand.GetChromiumDriver[TDriverOptions,TDriver,TDriverService](String driverName, Func`2 getDriverService, ILogger logger) in /_/src/Microsoft.DotNet.XHarness.CLI/Commands/WASM/Browser/WasmTestBrowserCommand.cs:line 210
                    at Microsoft.DotNet.XHarness.CLI.Commands.Wasm.WasmTestBrowserCommand.GetChromeDriver(ILogger logger) in /_/src/Microsoft.DotNet.XHarness.CLI/Commands/WASM/Browser/WasmTestBrowserCommand.cs:line 127
                    at Microsoft.DotNet.XHarness.CLI.Commands.Wasm.WasmTestBrowserCommand.InvokeInternal(ILogger logger) in /_/src/Microsoft.DotNet.XHarness.CLI/Commands/WASM/Browser/WasmTestBrowserCommand.cs:line 62
                    at Microsoft.DotNet.XHarness.Common.CLI.Commands.XHarnessCommand.Invoke(IEnumerable`1 arguments) in /_/src/Microsoft.DotNet.XHarness.Common/CLI/Commands/XHarnessCommand.cs:line 120

Sometimes starting the chromedriver can fail, and that can just be an
intermittent issue. For that reason, we have retry logic which is based
on check the `WebDriverException`'s message for certain strings.

But the way the driver service is created changed in
7a34cdf, to use reflection, which meant
that the `WebDriverException` is thrown wrapped in a
`TargetInvocationException`, which then breaks our retry checks.

```
[02:56:47] crit: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
                  ---> OpenQA.Selenium.WebDriverException: Cannot start the driver service on http://localhost:39881/
                    at OpenQA.Selenium.DriverService.Start()
                    at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)
                    at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
                    at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
                    at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
                    at OpenQA.Selenium.Chromium.ChromiumDriver..ctor(ChromiumDriverService service, ChromiumOptions options, TimeSpan commandTimeout)
                    at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout)
                    --- End of inner exception stack trace ---
                    at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
                    at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
                    at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture)
                    at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
                    at Microsoft.DotNet.XHarness.CLI.Commands.Wasm.WasmTestBrowserCommand.GetChromiumDriver[TDriverOptions,TDriver,TDriverService](String driverName, Func`2 getDriverService, ILogger logger) in /_/src/Microsoft.DotNet.XHarness.CLI/Commands/WASM/Browser/WasmTestBrowserCommand.cs:line 210
                    at Microsoft.DotNet.XHarness.CLI.Commands.Wasm.WasmTestBrowserCommand.GetChromeDriver(ILogger logger) in /_/src/Microsoft.DotNet.XHarness.CLI/Commands/WASM/Browser/WasmTestBrowserCommand.cs:line 127
                    at Microsoft.DotNet.XHarness.CLI.Commands.Wasm.WasmTestBrowserCommand.InvokeInternal(ILogger logger) in /_/src/Microsoft.DotNet.XHarness.CLI/Commands/WASM/Browser/WasmTestBrowserCommand.cs:line 62
                    at Microsoft.DotNet.XHarness.Common.CLI.Commands.XHarnessCommand.Invoke(IEnumerable`1 arguments) in /_/src/Microsoft.DotNet.XHarness.Common/CLI/Commands/XHarnessCommand.cs:line 120
```
@radical radical added the wasm WASM area label Mar 19, 2021
@radical radical merged commit dfce3c1 into dotnet:main Mar 19, 2021
@radical radical deleted the fix-chrome-retry branch March 19, 2021 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wasm WASM area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants