Skip to content

Commit

Permalink
Adds handling exception when stopping proxy. Closes #944
Browse files Browse the repository at this point in the history
  • Loading branch information
waldekmastykarz committed Nov 20, 2024
1 parent 1d349a1 commit 729e72b
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions dev-proxy/ProxyEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,19 +160,26 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
}
_pluginEvents.AfterRequestLog += AfterRequestLogAsync;

while (!stoppingToken.IsCancellationRequested && _proxyServer.ProxyRunning)

try
{
while (!Console.KeyAvailable)
while (!stoppingToken.IsCancellationRequested && _proxyServer.ProxyRunning)
{
await Task.Delay(10, stoppingToken);
}
// we need this check or proxy will fail with an exception
// when run for example in VSCode's integrated terminal
if (isInteractive)
{
await ReadKeysAsync();
while (!Console.KeyAvailable)
{
await Task.Delay(10, stoppingToken);
}
// we need this check or proxy will fail with an exception
// when run for example in VSCode's integrated terminal
if (isInteractive)
{
await ReadKeysAsync();
}
}
}
catch (TaskCanceledException)
{
}
}

private void FirstRunSetup()
Expand Down

0 comments on commit 729e72b

Please sign in to comment.