Skip to content

Commit b0edca9

Browse files
committed
Fix process exit throwing
1 parent 5d94ad6 commit b0edca9

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/PowerShellEditorServices/Services/PowerShell/Handlers/EvaluateHandler.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Microsoft.Extensions.Logging;
88
using Microsoft.PowerShell.EditorServices.Services.PowerShell;
99
using Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution;
10+
using Microsoft.PowerShell.EditorServices.Utility;
1011

1112
namespace Microsoft.PowerShell.EditorServices.Handlers
1213
{
@@ -36,7 +37,8 @@ public Task<EvaluateResponseBody> Handle(EvaluateRequestArguments request, Cance
3637
_executionService.ExecutePSCommandAsync(
3738
new PSCommand().AddScript(request.Expression),
3839
CancellationToken.None,
39-
new PowerShellExecutionOptions { WriteInputToHost = true, WriteOutputToHost = true, AddToHistory = true, ThrowOnError = false, InterruptCurrentForeground = true });
40+
new PowerShellExecutionOptions { WriteInputToHost = true, WriteOutputToHost = true, AddToHistory = true, ThrowOnError = false, InterruptCurrentForeground = true })
41+
.HandleErrorsAsync(_logger);
4042

4143
return Task.FromResult(new EvaluateResponseBody
4244
{

test/PowerShellEditorServices.Test.E2E/Processes/StdioServerProcess.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,15 @@ public override Task Start()
118118
/// <summary>
119119
/// Stop or disconnect from the server.
120120
/// </summary>
121-
public override async Task Stop()
121+
public override Task Stop()
122122
{
123123
Process serverProcess = Interlocked.Exchange(ref _serverProcess, null);
124+
ServerExitCompletion.TrySetResult(null);
124125
if (serverProcess != null && !serverProcess.HasExited)
125126
{
126127
serverProcess.Kill();
127128
}
128-
129-
await ServerExitCompletion.Task.ConfigureAwait(false);
129+
return ServerExitCompletion.Task;
130130
}
131131

132132
public event EventHandler<ProcessExitedArgs> ProcessExited;

0 commit comments

Comments
 (0)