Fix daemon relay exit classification - #84666
Merged
dibarbet merged 7 commits intoJul 29, 2026
Merged
Conversation
Classify relay completion by the endpoint that caused each copy direction to stop, so a lost daemon or editor cannot be mistaken for a clean shutdown. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f809f59b-563b-4a70-b5ea-df3af70d5abd
|
Azure Pipelines: Successfully started running 2 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the roslyn-language-server thin client’s daemon relay shutdown logic so it can reliably distinguish a clean LSP shutdown from loss of either the editor or daemon endpoint, avoiding incorrectly returning exit code 0 when the daemon is killed.
Changes:
- Replace the relay “both sides closed” heuristic with an explicit
RelayCompletionKindclassification. - Determine clean shutdown vs. editor/daemon connection loss by comparing the endpoints reported by each relay direction.
Show a summary per file
| File | Description |
|---|---|
| src/LanguageServer/roslyn-language-server/Program.cs | Consumes the new relay completion classification to choose the correct exit code (success vs. editor/daemon lost). |
| src/LanguageServer/roslyn-language-server/LspRelay.cs | Introduces RelayCompletionKind and updates relay completion logic to classify shutdown based on which endpoint each copy direction reports. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 0
JoeRobich
approved these changes
Jul 28, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f809f59b-563b-4a70-b5ea-df3af70d5abd
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f809f59b-563b-4a70-b5ea-df3af70d5abd
…-fix-daemon-relay-exit-code
…-fix-daemon-relay-exit-code
…-fix-daemon-relay-exit-code
Contributor
There was a problem hiding this comment.
Copilot's findings
Comments suppressed due to low confidence (1)
src/LanguageServer/roslyn-language-server/LspRelay.cs:41
RelayAsyncnow awaitscompletedTaskbefore canceling the other copy direction. IfCopyUntilClosedAsyncfaults unexpectedly, this will throw beforecancellationSource.Cancel()runs, potentially leaving the other copy task running and holding resources/streams open. Wrapping the awaits in a try/finally (or deferring the await until after cancel) keeps the previous guarantee that the non-winning direction is always canceled.
var completedTask = await Task.WhenAny(editorToServer, serverToEditor).ConfigureAwait(false);
var closedEndpoint = await completedTask.ConfigureAwait(false);
// Give the other direction a brief window to finish on its own. If both copies terminate at the server,
// the server connection was lost and caused both directions to stop. Any other pair is a clean shutdown:
- Files reviewed: 2/2 changed files
- Comments generated: 0 new
JoeRobich
reviewed
Jul 28, 2026
JoeRobich
approved these changes
Jul 28, 2026
GoldMikeDev
pushed a commit
to GoldMikeDev/FollyOfTheUnbound
that referenced
this pull request
Jul 29, 2026
Follow-up to the origin/main merge: our fork's LspRelay.RelayAsync classifier was merged with upstream's own recent fix for the same class of bug (dotnet#84666, "Fix daemon relay exit classification") -- keeping our fork's more complete algorithm (graceful/ungraceful tracking, so a server that closes cleanly without the editor also closing is still classified as clean, which upstream's own fix doesn't cover) under upstream's cleaner RelayCompletionKind enum API. Updated this fork's own LspRelay tests to match the merged signature; all 4 still pass with the same semantics.
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.
Fixes #84662
When the daemon endpoint is lost, both directional relay tasks can complete against the server endpoint. The thin client previously interpreted any pair of completed relay tasks as a clean shutdown and returned exit code 0.
Classify relay completion using the endpoint reported by each copy direction:
A clean editor shutdown may complete both copies at the editor because the editor closes its bidirectional transport after sending LSP
exit, before the daemon closes its side.Validation:
src\LanguageServer\roslyn-language-server\roslyn-language-server.csprojKeepAlive_DaemonReusedWithinWindow_ThenExitsWhenIdlein Release (passed)Microsoft Reviewers: Open in CodeFlow