diff --git a/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHttpListener.cs b/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHttpListener.cs index 72804afd..25ec5949 100644 --- a/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHttpListener.cs +++ b/src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHttpListener.cs @@ -92,15 +92,15 @@ public sealed class OpenIddictClientSystemIntegrationHttpListener : BackgroundSe } // Ignore exceptions indicating that the host is shutting down and return immediately. - catch (OperationCanceledException) when (stoppingToken.IsCancellationRequested) + catch (OperationCanceledException exception) when (stoppingToken.IsCancellationRequested) { - _source.SetResult(result: null); + _source.TrySetException(exception); return; } catch (Exception exception) when (!OpenIddictHelpers.IsFatal(exception)) { - _source.SetResult(result: null); + _source.TrySetException(exception); throw; }