Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions dotnet/src/webdriver/DriverService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,16 @@ public void Start()
DriverProcessStartingEventArgs eventArgs = new DriverProcessStartingEventArgs(this.driverServiceProcess.StartInfo);
this.OnDriverProcessStarting(eventArgs);

// Important: Start the process and immediately begin reading the output and error streams to avoid IO deadlocks.
this.driverServiceProcess.Start();
this.driverServiceProcess.BeginOutputReadLine();
this.driverServiceProcess.BeginErrorReadLine();

bool serviceAvailable = this.WaitForServiceInitialization();

DriverProcessStartedEventArgs processStartedEventArgs = new DriverProcessStartedEventArgs(this.driverServiceProcess);
this.OnDriverProcessStarted(processStartedEventArgs);

this.driverServiceProcess.BeginOutputReadLine();
this.driverServiceProcess.BeginErrorReadLine();

if (!serviceAvailable)
{
throw new WebDriverException($"Cannot start the driver service on {this.ServiceUrl}");
Expand All @@ -286,6 +288,12 @@ protected virtual void Dispose(bool disposing)
if (disposing)
{
this.Stop();

if (this.driverServiceProcess is not null)
{
this.driverServiceProcess.OutputDataReceived -= this.OnDriverProcessDataReceived;
this.driverServiceProcess.ErrorDataReceived -= this.OnDriverProcessDataReceived;
}
}

this.isDisposed = true;
Expand Down
5 changes: 2 additions & 3 deletions dotnet/src/webdriver/Firefox/FirefoxDriverService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ protected override void OnDriverProcessStarting(DriverProcessStartingEventArgs e
/// </summary>
/// <param name="sender">The sender of the event.</param>
/// <param name="args">The data received event arguments.</param>
/// <param name="isError">A value indicating whether the data received is from the error stream.</param>
protected override void OnDriverProcessDataReceived(object sender, DataReceivedEventArgs args)
{
if (string.IsNullOrEmpty(args.Data))
Expand Down Expand Up @@ -279,13 +278,13 @@ protected override void OnDriverProcessDataReceived(object sender, DataReceivedE
/// </remarks>
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);

if (logWriter != null && disposing)
{
logWriter.Dispose();
logWriter = null;
}

base.Dispose(disposing);
}

/// <summary>
Expand Down
Loading