[dotnet] Asynchronously start driver service (breaking change)#17108
[dotnet] Asynchronously start driver service (breaking change)#17108nvborisenko merged 2 commits intoSeleniumHQ:trunkfrom
Conversation
PR TypeEnhancement Description
|
| Relevant files | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Enhancement |
|
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
|||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||||||||
There was a problem hiding this comment.
Pull request overview
Updates the .NET WebDriver binding to start driver services asynchronously, enabling cancellation to propagate through driver discovery and the service initialization wait loop.
Changes:
- Replaces synchronous
DriverService.Start()usage withawait DriverService.StartAsync(...)in multiple drivers. - Refactors
DriverServicestartup to use async driver discovery and async initialization waiting (withCancellationTokensupport). - Adds
CancellationTokensupport toDriverFinderAPIs and passes it through to Selenium Manager discovery.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| dotnet/src/webdriver/DriverService.cs | Replaces sync start with StartAsync(CancellationToken) and awaits driver discovery + initialization polling. |
| dotnet/src/webdriver/DriverFinder.cs | Adds optional CancellationToken to async path discovery methods and propagates it to Selenium Manager. |
| dotnet/src/webdriver/Chromium/ChromiumDriver.cs | Uses await service.StartAsync() when creating the command executor. |
| dotnet/src/webdriver/Firefox/FirefoxDriver.cs | Uses await service.StartAsync() when creating the command executor. |
| dotnet/src/webdriver/IE/InternetExplorerDriver.cs | Uses await service.StartAsync() when creating the command executor. |
| dotnet/src/webdriver/Safari/SafariDriver.cs | Uses await service.StartAsync() when creating the command executor. |
Comments suppressed due to low confidence (1)
dotnet/src/webdriver/DriverService.cs:200
- StartAsync assigns driverServiceProcess before any awaits. If StartAsync is called concurrently, a second caller can see a non-null driverServiceProcess and return immediately even though the service hasn’t been started/initialized yet (first call is still awaiting). Consider guarding startup with a single in-flight Task/ValueTask (e.g., SemaphoreSlim or a cached start task) so concurrent callers await the same initialization, or only assign driverServiceProcess after the process has started and initialization has completed.
if (this.driverServiceProcess != null)
{
return;
}
this.driverServiceProcess = new Process();
Before:
After:
Intentionally changed method signature (breaking change). I expect only 0.01% of users are affected. Even Appium, who inherits this class, doesn't use this method :)
🔗 Related Issues
Contributes to #17086
💥 What does this PR do?
Refactors the driver service startup process to be fully asynchronous and to support cancellation via
CancellationToken. The main changes include updating the driver service start methods to be asynchronous, propagating cancellation tokens throughout the driver discovery and startup process, and updating related method signatures and documentation accordingly.🔄 Types of changes