Skip to content

Commit ed29442

Browse files
Adds handling exception when stopping proxy. Closes #944 (#946)
1 parent cd403b6 commit ed29442

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

dev-proxy/ProxyEngine.cs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -160,19 +160,26 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
160160
}
161161
_pluginEvents.AfterRequestLog += AfterRequestLogAsync;
162162

163-
while (!stoppingToken.IsCancellationRequested && _proxyServer.ProxyRunning)
163+
164+
try
164165
{
165-
while (!Console.KeyAvailable)
166+
while (!stoppingToken.IsCancellationRequested && _proxyServer.ProxyRunning)
166167
{
167-
await Task.Delay(10, stoppingToken);
168-
}
169-
// we need this check or proxy will fail with an exception
170-
// when run for example in VSCode's integrated terminal
171-
if (isInteractive)
172-
{
173-
await ReadKeysAsync();
168+
while (!Console.KeyAvailable)
169+
{
170+
await Task.Delay(10, stoppingToken);
171+
}
172+
// we need this check or proxy will fail with an exception
173+
// when run for example in VSCode's integrated terminal
174+
if (isInteractive)
175+
{
176+
await ReadKeysAsync();
177+
}
174178
}
175179
}
180+
catch (TaskCanceledException)
181+
{
182+
}
176183
}
177184

178185
private void FirstRunSetup()

0 commit comments

Comments
 (0)