Skip to content

Ensure we don't log errors when we are cancelling loading - #84622

Merged
jasonmalinowski merged 1 commit into
dotnet:mainfrom
jasonmalinowski:fix-cancellation-exception-in-load-during-shutdown
Jul 28, 2026
Merged

jasonmalinowski merged 1 commit into
dotnet:mainfrom
jasonmalinowski:fix-cancellation-exception-in-load-during-shutdown

Conversation

@jasonmalinowski

@jasonmalinowski jasonmalinowski commented Jul 24, 2026

Copy link
Copy Markdown
Member

We passed around a cancellation token through the project loading path, but never really expected it to be fired, since no token was passed to the AsyncBatchingWorkQueue. It turns out that when we made things more disposable, we'd dispose that queue which does cancel the work. Ensure that in that case, we don't log silly errors.

Fixes #84619

Microsoft Reviewers: Open in CodeFlow

@jasonmalinowski jasonmalinowski self-assigned this Jul 24, 2026
Copilot AI review requested due to automatic review settings July 24, 2026 21:28
@jasonmalinowski
jasonmalinowski requested a review from a team as a code owner July 24, 2026 21:28
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts Language Server project-loading error reporting so expected cancellation during disposal/shutdown doesn’t get logged as an error, reducing noisy/incorrect telemetry and user-visible log output during shutdown.

Changes:

  • Adds clarifying commentary that AsyncBatchingWorkQueue.Dispose() is sufficient to cancel pending/in-flight project reload work (no separate shutdown token needed).
  • Avoids logging/reporting exceptions from the project reload path when the failure is due to cancellation (OperationCanceledException), which is expected during shutdown/dispose.
Show a summary per file
File Description
src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerProjectLoader.cs Suppresses error logging for cancellation during project reload and clarifies queue cancellation behavior on disposal.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 1

We passed around a cancellation token through the project loading path,
but never really expected it to be fired, since no token was passed
to the AsyncBatchingWorkQueue. It turns out that when we made things
more disposable, we'd dispose that queue which does cancel the work.
Ensure that in that case, we don't log silly errors.

Fixes dotnet#84619
Copilot AI review requested due to automatic review settings July 27, 2026 20:47
@jasonmalinowski
jasonmalinowski force-pushed the fix-cancellation-exception-in-load-during-shutdown branch from e3f546f to 1603edd Compare July 27, 2026 20:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 1

@jasonmalinowski
jasonmalinowski merged commit bd978cd into dotnet:main Jul 28, 2026
25 checks passed
@jasonmalinowski
jasonmalinowski deleted the fix-cancellation-exception-in-load-during-shutdown branch July 28, 2026 18:52
jasonmalinowski added a commit that referenced this pull request Aug 5, 2026
… uses (#84712)

AsyncBatchingWorkQueue was disposable, and also took a CancellationToken
which could be used to cancel the work in the queue and also prevent
future work. Dispose however was a bit strange: it would cancel work,
but not free it and wouldn't prevent queueing of new work. This unifies
the behavior: Dispose() now will also clear work and prevent future
work. The cancellation token that's accepted in the constructor is just
a convenience for calling Dispose().

This behavior was what lead to
#84622 -- there we realized we had
a queue cancelling we didn't really expect, but since it didn't prevent
future work being queued you could still get more work running.

The first commit in this PR fixes AsyncBatchingWorkQueue, and then the
follow up commits migrate all the easy uses of AsyncBatchingWorkQueue to
use Disposal when possible. We had cases where we just forgot to shut
down the queue but could do so, and cases where we had a token just to
shut this down that can be written more easily now.
@jjonescz jjonescz added this to the 18.11 milestone Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Project loading reports cancellation error on shutdown

5 participants