Ensure we don't log errors when we are cancelling loading - #84622
Merged
jasonmalinowski merged 1 commit intoJul 28, 2026
Merged
jasonmalinowski merged 1 commit into
jasonmalinowski merged 1 commit into
Conversation
|
Azure Pipelines: Successfully started running 2 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
dibarbet
approved these changes
Jul 24, 2026
JoeRobich
approved these changes
Jul 24, 2026
Contributor
There was a problem hiding this comment.
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
jasonmalinowski
force-pushed
the
fix-cancellation-exception-in-load-during-shutdown
branch
from
July 27, 2026 20:47
e3f546f to
1603edd
Compare
JoeRobich
approved these changes
Jul 27, 2026
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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