diff --git a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerProjectLoader.cs b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerProjectLoader.cs index 5da39526ae5c5..4707a730f9651 100644 --- a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerProjectLoader.cs +++ b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerProjectLoader.cs @@ -140,7 +140,9 @@ protected LanguageServerProjectLoader( ReloadProjectsAsync, ProjectToLoad.Comparer, Listener, - CancellationToken.None); // TODO: do we need to introduce a shutdown cancellation token for this? + // We don't need a separate shutdown cancellation token here: Dispose() disposes the work queue, and that + // cancels any in-flight batch along with any work that hasn't started yet. + CancellationToken.None); } private static ImmutableDictionary BuildAdditionalProperties(ServerConfiguration? serverConfiguration) @@ -387,7 +389,7 @@ await primordial.PrimordialProjectFactory.ApplyChangeToWorkspaceAsync( return projectRestorePath; } - catch (Exception e) + catch (Exception e) when (!ExceptionUtilities.IsCurrentOperationBeingCancelled(e, cancellationToken)) // Cancellation is only expected when we're shutting down, in which case there's no reason to do a report. { // Since our LogDiagnosticsAsync helper takes DiagnosticLogItems, let's just make one for this var message = string.Format(LanguageServerResources.Exception_thrown_0, e);