dotnet / dotnet/vscode-csharp

Integration diagnostic tests fail with "Stopping server timed out"

Open
#7,003 0 comments 0 reactions 1 assignee Claimed by @dibarbet View on GitHub
Test Triaged
Dominant language
TypeScript
Stars
3.1k
Forks
737
Avg merge
18h 40m
Merged PRs (30d)
31

Description

The diagnostics integration tests can be flaky when it restarts the server to set the analyzer options. From the C# logs we can see the following:
```
[Info - 12:43:51 AM] [LanguageServerProjectSystem] Completed (re)load of all projects in 00:00:02.3189086
[BuildHost PID 9707] Sending a Shutdown request to the BuildHost.
[BuildHost PID 9707] Process shut down.
[BuildHost PID 9707] Message from Process: info: Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.Program[0]
[BuildHost PID 9707] Message from Process: RPC channel closed; process exiting.
[BuildHost PID 9702] Sending a Shutdown request to the BuildHost.
[BuildHost PID 9702] Message from Process: info: Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.Program[0]
[BuildHost PID 9702] Message from Process: RPC channel closed; process exiting.
[BuildHost PID 9702] Process shut down.
[LanguageServerHost] [12:43:51.702][End]solution/open
[LanguageServerHost] [12:43:51.703][Start]workspace/debugConfiguration
[LanguageServerHost] [12:43:51.719][End]workspace/debugConfiguration
[LanguageServerHost] [12:43:51.838][Start]textDocument/didOpen
[LanguageServerHost] [12:43:51.840][Start]workspace/buildOnlyDiagnosticIds
[LanguageServerHost] didOpen for file:///Users/runner/work/1/s/test/integrationTests/testAssets/slnWithCsproj/src/app/diagnostics.cs
[LanguageServerHost] [12:43:51.857][End]textDocument/didOpen
[LanguageServerHost] [12:43:51.886][Start]workspace/didChangeWatchedFiles
[LanguageServerHost] [12:43:51.887][End]workspace/didChangeWatchedFiles
[LanguageServerHost] /Users/runner/work/1/s/test/integrationTests/testAssets/slnWithCsproj/src/app/diagnostics.cs found in workspace Host
[LanguageServerHost] [12:43:51.907][Start]textDocument/documentSymbol
[LanguageServerHost] /Users/runner/work/1/s/test/integrationTests/testAssets/slnWithCsproj/src/app/diagnostics.cs found in workspace Host
[LanguageServerHost] [12:43:51.910][Start]textDocument/documentHighlight
[LanguageServerHost] [12:43:52.507][Start]workspace/didChangeWatchedFiles
[LanguageServerHost] [12:43:52.509][End]workspace/didChangeWatchedFiles
[LanguageServerHost] /Users/runner/work/1/s/test/integrationTests/testAssets/slnWithCsproj/src/app/diagnostics.cs found in workspace Host
[LanguageServerHost] /Users/runner/work/1/s/test/integrationTests/testAssets/slnWithCsproj/src/app/diagnostics.cs found in workspace Host
[LanguageServerHost] [12:43:52.761][Start]workspace/buildOnlyDiagnosticIds
[BuildHost PID 9842] Message from Process: info: Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.Program[0]
[BuildHost PID 9842] Message from Process: BuildHost Runtime Version: .NET 8.0.2
[LanguageServerHost] [12:43:52.813][Start]textDocument/inlayHint
[LanguageServerHost] [12:43:52.819][Start]textDocument/foldingRange
[LanguageServerHost] [12:43:52.838][End]textDocument/inlayHint
[LanguageServerHost] [12:43:52.931][End]textDocument/foldingRange
[LanguageServerHost] /Users/runner/work/1/s/test/integrationTests/testAssets/slnWithCsproj/src/app/diagnostics.cs found in workspace Host
[LanguageServerHost] [12:43:52.947][Start]textDocument/documentSymbol
[LanguageServerHost] [12:43:53.013][Start]workspace/buildOnlyDiagnosticIds
[BuildHost PID 9842] Message from Process: info: Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.BuildHost[0]
[BuildHost PID 9842] Message from Process: Registered MSBuild instance at /Users/runner/.dotnet/sdk/8.0.201
[LanguageServerHost] Shutting down
[Info - 12:43:53 AM] Shutting down
[Error - 12:43:55 AM] Stopping server timed out
[LanguageServerHost] textDocument/documentHighlight - Canceled
[LanguageServerHost] [12:43:53.136][End]textDocument/documentHighlight
[BuildHost PID 9842] Message from Process: info: Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.BuildHost[0]
[BuildHost PID 9842] Message from Process: Loading /Users/runner/work/1/s/test/integrationTests/testAssets/slnWithCsproj/test/test.csproj
[LanguageServerHost] [12:43:53.371][End]textDocument/documentSymbol
[LanguageServerHost] [12:43:53.373][End]textDocument/documentSymbol
Language server process exited with 0
```

It appears as though the project is reloading while the test is in progress. The project reloading delays shutdown long enough for the client to timeout on stopping (though it eventually does shutdown).

The reload is caused by the `didChangeWatchedFiles` request. Digging into the C# LSP trace logs, we can see a corresponding request at the same time for files in the obj folder.
```
[Trace - 12:43:51 AM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {
"changes": [
{
"uri": "file:///Users/runner/work/1/s/test/integrationTests/testAssets/slnWithCsproj/test/obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs",
"type": 1
},
{
"uri": "file:///Users/runner/work/1/s/test/integrationTests/testAssets/slnWithCsproj/test/obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs",
"type": 1
},
{
"uri": "file:///Users/runner/work/1/s/test/integrationTests/testAssets/slnWithCsproj/test/obj/Debug/net8.0/test.GeneratedMSBuildEditorConfig.editorconfig",
"type": 1
}
]
}
```

These file changes should not be triggering a reload as the files are generated by the design time build. Related to https://github.com/dotnet/roslyn/pull/72625

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.