microsoft / vscode-dotnettools

This is a feedback repository to capture issues logged for the C# Dev Kit and related extensions from Visual Studio Code
Other
229 stars 12 forks source link

[BUG] LanguageServerHost crash #1446

Closed Felx-B closed 1 month ago

Felx-B commented 1 month ago

Describe the Issue

Hi,

I often have the LanguageServerHost crashing, and when that happens, I lose IntelliSense. I have to restart VSCode for it to work again.

Here is C# console output

[Error - 16:00:33] [LanguageServerHost] System.ArgumentException: '<Document59312630-2d02-40ad-a2b1-bc6f37a12394>' ne fait pas partie de l'espace de travail.
   at Microsoft.CodeAnalysis.Workspace.<>c.<OnDocumentClosedEx>b__213_0(Solution oldSolution, ValueTuple`4 data) in /_/src/Workspaces/Core/Portable/Workspace/Workspace_Editor.cs:line 662
   at Microsoft.CodeAnalysis.Workspace.SetCurrentSolutionAsync[TData](Boolean useAsync, TData data, Func`3 transformation, Boolean mayRaiseEvents, Action`3 onBeforeUpdate, Action`3 onAfterUpdate, CancellationToken cancellationToken) in /_/src/Workspaces/Core/Portable/Workspace/Workspace.cs:line 511
   at Roslyn.Utilities.ValueTaskExtensions.VerifyCompleted[T](ValueTask`1 task, String message) in /_/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/ValueTaskExtensions.cs:line 21
   at Microsoft.CodeAnalysis.Workspace.SetCurrentSolution[TData](TData data, Func`3 transformation, Boolean mayRaiseEvents, Action`3 onBeforeUpdate, Action`3 onAfterUpdate) in /_/src/Workspaces/Core/Portable/Workspace/Workspace.cs:line 472
   at Microsoft.CodeAnalysis.Workspace.OnDocumentClosedEx(DocumentId documentId, TextLoader reloader, Boolean requireDocumentPresentAndOpen) in /_/src/Workspaces/Core/Portable/Workspace/Workspace_Editor.cs:line 650
   at Microsoft.CodeAnalysis.PdbSourceDocument.PdbSourceDocumentMetadataAsSourceFileProvider.TryRemoveDocumentFromWorkspace(MetadataAsSourceWorkspace workspace, String filePath) in /_/src/Features/Core/Portable/PdbSourceDocument/PdbSourceDocumentMetadataAsSourceFileProvider.cs:line 385
   at Microsoft.CodeAnalysis.MetadataAsSource.MetadataAsSourceFileService.TryRemoveDocumentFromWorkspace(String filePath) in /_/src/Features/Core/Portable/MetadataAsSource/MetadataAsSourceFileService.cs:line 203
   at Microsoft.CodeAnalysis.LanguageServer.LspMiscellaneousFilesWorkspace.TryRemoveMiscellaneousDocument(Uri uri, Boolean removeFromMetadataWorkspace) in /_/src/LanguageServer/Protocol/Workspaces/LspMiscellaneousFilesWorkspace.cs:line 80
   at Microsoft.CodeAnalysis.LanguageServer.LspWorkspaceManager.StopTrackingAsync(Uri uri, CancellationToken cancellationToken) in /_/src/LanguageServer/Protocol/Workspaces/LspWorkspaceManager.cs:line 199
   at Microsoft.CodeAnalysis.LanguageServer.Handler.DocumentChanges.DidCloseHandler.HandleNotificationAsync(DidCloseTextDocumentParams request, RequestContext context, CancellationToken cancellationToken) in /_/src/LanguageServer/Protocol/Handler/DocumentChanges/DidCloseHandler.cs:line 36
   at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`1.StartRequestAsync[TRequest,TResponse](TRequest request, TRequestContext context, IMethodHandler handler, String language, CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 199
[Error - 16:00:33] [LanguageServerHost] System.ArgumentException: '<Document59312630-2d02-40ad-a2b1-bc6f37a12394>' ne fait pas partie de l'espace de travail.
   at Microsoft.CodeAnalysis.Workspace.<>c.<OnDocumentClosedEx>b__213_0(Solution oldSolution, ValueTuple`4 data) in /_/src/Workspaces/Core/Portable/Workspace/Workspace_Editor.cs:line 662
   at Microsoft.CodeAnalysis.Workspace.SetCurrentSolutionAsync[TData](Boolean useAsync, TData data, Func`3 transformation, Boolean mayRaiseEvents, Action`3 onBeforeUpdate, Action`3 onAfterUpdate, CancellationToken cancellationToken) in /_/src/Workspaces/Core/Portable/Workspace/Workspace.cs:line 511
   at Roslyn.Utilities.ValueTaskExtensions.VerifyCompleted[T](ValueTask`1 task, String message) in /_/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/ValueTaskExtensions.cs:line 21
   at Microsoft.CodeAnalysis.Workspace.SetCurrentSolution[TData](TData data, Func`3 transformation, Boolean mayRaiseEvents, Action`3 onBeforeUpdate, Action`3 onAfterUpdate) in /_/src/Workspaces/Core/Portable/Workspace/Workspace.cs:line 472
   at Microsoft.CodeAnalysis.Workspace.OnDocumentClosedEx(DocumentId documentId, TextLoader reloader, Boolean requireDocumentPresentAndOpen) in /_/src/Workspaces/Core/Portable/Workspace/Workspace_Editor.cs:line 650
   at Microsoft.CodeAnalysis.PdbSourceDocument.PdbSourceDocumentMetadataAsSourceFileProvider.TryRemoveDocumentFromWorkspace(MetadataAsSourceWorkspace workspace, String filePath) in /_/src/Features/Core/Portable/PdbSourceDocument/PdbSourceDocumentMetadataAsSourceFileProvider.cs:line 385
   at Microsoft.CodeAnalysis.MetadataAsSource.MetadataAsSourceFileService.TryRemoveDocumentFromWorkspace(String filePath) in /_/src/Features/Core/Portable/MetadataAsSource/MetadataAsSourceFileService.cs:line 203
   at Microsoft.CodeAnalysis.LanguageServer.LspMiscellaneousFilesWorkspace.TryRemoveMiscellaneousDocument(Uri uri, Boolean removeFromMetadataWorkspace) in /_/src/LanguageServer/Protocol/Workspaces/LspMiscellaneousFilesWorkspace.cs:line 80
   at Microsoft.CodeAnalysis.LanguageServer.LspWorkspaceManager.StopTrackingAsync(Uri uri, CancellationToken cancellationToken) in /_/src/LanguageServer/Protocol/Workspaces/LspWorkspaceManager.cs:line 199
   at Microsoft.CodeAnalysis.LanguageServer.Handler.DocumentChanges.DidCloseHandler.HandleNotificationAsync(DidCloseTextDocumentParams request, RequestContext context, CancellationToken cancellationToken) in /_/src/LanguageServer/Protocol/Handler/DocumentChanges/DidCloseHandler.cs:line 36
   at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`1.StartRequestAsync[TRequest,TResponse](TRequest request, TRequestContext context, IMethodHandler handler, String language, CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 199
   at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`1.StartRequestAsync[TRequest,TResponse](TRequest request, TRequestContext context, IMethodHandler handler, String language, CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 241
   at Microsoft.CodeAnalysis.LanguageServer.RoslynRequestExecutionQueue.WrapStartRequestTaskAsync(Task nonMutatingRequestTask, Boolean rethrowExceptions) in /_/src/LanguageServer/Protocol/RoslynRequestExecutionQueue.cs:line 40
   at Microsoft.CommonLanguageServerProtocol.Framework.RequestExecutionQueue`1.ProcessQueueCoreAsync[TRequest,TResponse](IQueueItem`1 work, IMethodHandler handler, RequestHandlerMetadata metadata, ConcurrentDictionary`2 concurrentlyExecutingTasks, CancellationTokenSource currentWorkCts, CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs:line 349
   at Microsoft.CommonLanguageServerProtocol.Framework.RequestExecutionQueue`1.InvokeProcessCoreAsync(IQueueItem`1 work, RequestHandlerMetadata metadata, IMethodHandler handler, MethodInfo methodInfo, ConcurrentDictionary`2 concurrentlyExecutingTasks, CancellationTokenSource currentWorkCts, CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs:line 302
   at Microsoft.CommonLanguageServerProtocol.Framework.RequestExecutionQueue`1.ProcessQueueAsync() in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs:line 254
[Info  - 16:00:33] Error processing queue, shutting down
[Info  - 16:00:33] Connection to server got closed. Server will restart.
true
Using dotnet configured on PATH
Dotnet path: /usr/local/share/dotnet/dotnet
Activating C# + C# Dev Kit...
waiting for named pipe information from server...
[stdout] fail: Microsoft.CodeAnalysis.LanguageServer.ExportProviderBuilder[0]
      /Users/fborot/.vscode/extensions/ms-dotnettools.csharp-2.45.20-darwin-arm64/.xamlTools/Microsoft.VisualStudio.DesignTools.CodeAnalysis.dll with assembly name Microsoft.VisualStudio.DesignTools.CodeAnalysis, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a conflicts with extension loaded from /Users/fborot/.vscode/extensions/ms-dotnettools.csharp-2.45.20-darwin-arm64/.xamlTools
fail: Microsoft.CodeAnalysis.LanguageServer.ExportProviderBuilder[0]
      /Users/fborot/.vscode/extensions/ms-dotnettools.csharp-2.45.20-darwin-arm64/.xamlTools/Microsoft.VisualStudio.DesignTools.CodeAnalysis.Diagnostics.dll with assembly name Microsoft.VisualStudio.DesignTools.CodeAnalysis.Diagnostics, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a conflicts with extension loaded from /Users/fborot/.vscode/extensions/ms-dotnettools.csharp-2.45.20-darwin-arm64/.xamlTools
[stdout] {"pipeName":"/var/folders/pj/nskzwcxd7vs50xr_lw61jkhm0000gp/T/f3d06c82.sock"}
received named pipe information from server
attempting to connect client to server...
client has connected to server
[Info  - 16:00:34] [Program] Language server initialized

What am I missing ? Thank you

Steps To Reproduce

No response

Expected Behavior

No response

Environment Information

VSCode 1.93.0 C# Dev Kit 1.10.16 Macbook Pro M1 Pro

einord commented 1 month ago

I have the same issue, perhaps related or at least to #1448 and #1451?

The C# Language server crashes for me all the time. Really annoying since I also use MacOS (arm), and I have to restart constantly.

[stdout] fail: Microsoft.CodeAnalysis.LanguageServer.ExportProviderBuilder[0]
      /Users/jonatannyqvist/.vscode/extensions/ms-dotnettools.csharp-2.45.20-darwin-arm64/.xamlTools/Microsoft.VisualStudio.DesignTools.CodeAnalysis.dll with assembly name Microsoft.VisualStudio.DesignTools.CodeAnalysis, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a conflicts with extension loaded from /Users/jonatannyqvist/.vscode/extensions/ms-dotnettools.csharp-2.45.20-darwin-arm64/.xamlTools
fail: Microsoft.CodeAnalysis.LanguageServer.ExportProviderBuilder[0]
      /Users/jonatannyqvist/.vscode/extensions/ms-dotnettools.csharp-2.45.20-darwin-arm64/.xamlTools/Microsoft.VisualStudio.DesignTools.CodeAnalysis.Diagnostics.dll with assembly name Microsoft.VisualStudio.DesignTools.CodeAnalysis.Diagnostics, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a conflicts with extension loaded from /Users/jonatannyqvist/.vscode/extensions/ms-dotnettools.csharp-2.45.20-darwin-arm64/.xamlTools
fail: Microsoft.CodeAnalysis.LanguageServer.ExportProviderBuilder[0]
      /Users/jonatannyqvist/.vscode/extensions/ms-dotnettools.csharp-2.45.20-darwin-arm64/.xamlTools/Microsoft.VisualStudio.DesignTools.CodeAnalysis.dll with assembly name Microsoft.VisualStudio.DesignTools.CodeAnalysis, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a conflicts with extension loaded from /Users/jonatannyqvist/.vscode/extensions/ms-dotnettools.csharp-2.45.20-darwin-arm64/.xamlTools
fail: Microsoft.CodeAnalysis.LanguageServer.ExportProviderBuilder[0]
      /Users/jonatannyqvist/.vscode/extensions/ms-dotnettools.csharp-2.45.20-darwin-arm64/.xamlTools/Microsoft.VisualStudio.DesignTools.CodeAnalysis.Diagnostics.dll with assembly name Microsoft.VisualStudio.DesignTools.CodeAnalysis.Diagnostics, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a conflicts with extension loaded from /Users/jonatannyqvist/.vscode/extensions/ms-dotnettools.csharp-2.45.20-darwin-arm64/.xamlTools
fail: Microsoft.CodeAnalysis.LanguageServer.ExportProviderBuilder[0]
      /Users/jonatannyqvist/.vscode/extensions/ms-dotnettools.csharp-2.45.20-darwin-arm64/.xamlTools/Microsoft.VisualStudio.DesignTools.CodeAnalysis.dll with assembly name Microsoft.VisualStudio.DesignTools.CodeAnalysis, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a conflicts with extension loaded from /Users/jonatannyqvist/.vscode/extensions/ms-dotnettools.csharp-2.45.20-darwin-arm64/.xamlTools
fail: Microsoft.CodeAnalysis.LanguageServer.ExportProviderBuilder[0]
      /Users/jonatannyqvist/.vscode/extensions/ms-dotnettools.csharp-2.45.20-darwin-arm64/.xamlTools/Microsoft.VisualStudio.DesignTools.CodeAnalysis.Diagnostics.dll with assembly name Microsoft.VisualStudio.DesignTools.CodeAnalysis.Diagnostics, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a conflicts with extension loaded from /Users/jonatannyqvist/.vscode/extensions/ms-dotnettools.csharp-2.45.20-darwin-arm64/.xamlTools
fail: Microsoft.CodeAnalysis.LanguageServer.ExportProviderBuilder[0]
      /Users/jonatannyqvist/.vscode/extensions/ms-dotnettools.csharp-2.45.20-darwin-arm64/.xamlTools/Microsoft.VisualStudio.DesignTools.CodeAnalysis.dll with assembly name Microsoft.VisualStudio.DesignTools.CodeAnalysis, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a conflicts with extension loaded from /Users/jonatannyqvist/.vscode/extensions/ms-dotnettools.csharp-2.45.20-darwin-arm64/.xamlTools
fail: Microsoft.CodeAnalysis.LanguageServer.ExportProviderBuilder[0]
      /Users/jonatannyqvist/.vscode/extensions/ms-dotnettools.csharp-2.45.20-darwin-arm64/.xamlTools/Microsoft.VisualStudio.DesignTools.CodeAnalysis.Diagnostics.dll with assembly name Microsoft.VisualStudio.DesignTools.CodeAnalysis.Diagnostics, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a conflicts with extension loaded from /Users/jonatannyqvist/.vscode/extensions/ms-dotnettools.csharp-2.45.20-darwin-arm64/.xamlTools
[stdout] {"pipeName":"/var/folders/68/7gq77cbs4vjg20sdq_pc2vr80000gn/T/080d9cb3.sock"}
received named pipe information from server
attempting to connect client to server...
client has connected to server
[Info  - 11:01:46] [Program] Language server initialized

I also seem to get these logs when the intelligence crashes the first time after restart:

[Error - 11:11:14] [LanguageServerHost] StreamJsonRpc.LocalRpcException: Resolve version '2024-09-10T09:11:13.7746290Z-10209-0' does not match current version '2024-09-10T09:11:14.0709070Z-10210-0'
   at Microsoft.CodeAnalysis.LanguageServer.Handler.CodeLens.CodeLensResolveHandler.HandleRequestAsync(CodeLens request, RequestContext context, CancellationToken cancellationToken) in /_/src/LanguageServer/Protocol/Handler/CodeLens/CodeLensResolveHandler.cs:line 55
   at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`1.StartRequestAsync[TRequest,TResponse](TRequest request, TRequestContext context, IMethodHandler handler, String language, CancellationToken cancellationToken)
[Error - 11:11:14] [LanguageServerHost] StreamJsonRpc.LocalRpcException: Resolve version '2024-09-10T09:11:13.7746290Z-10209-0' does not match current version '2024-09-10T09:11:14.0709070Z-10210-0'
   at Microsoft.CodeAnalysis.LanguageServer.Handler.CodeLens.CodeLensResolveHandler.HandleRequestAsync(CodeLens request, RequestContext context, CancellationToken cancellationToken) in /_/src/LanguageServer/Protocol/Handler/CodeLens/CodeLensResolveHandler.cs:line 55
   at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`1.StartRequestAsync[TRequest,TResponse](TRequest request, TRequestContext context, IMethodHandler handler, String language, CancellationToken cancellationToken)
[Error - 11:11:14] [LanguageServerHost] StreamJsonRpc.LocalRpcException: Resolve version '2024-09-10T09:11:13.7746290Z-10209-0' does not match current version '2024-09-10T09:11:14.0709070Z-10210-0'
   at Microsoft.CodeAnalysis.LanguageServer.Handler.CodeLens.CodeLensResolveHandler.HandleRequestAsync(CodeLens request, RequestContext context, CancellationToken cancellationToken) in /_/src/LanguageServer/Protocol/Handler/CodeLens/CodeLensResolveHandler.cs:line 55
   at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`1.StartRequestAsync[TRequest,TResponse](TRequest request, TRequestContext context, IMethodHandler handler, String language, CancellationToken cancellationToken)
[Error - 11:11:14] [LanguageServerHost] StreamJsonRpc.LocalRpcException: Resolve version '2024-09-10T09:11:13.7746290Z-10209-0' does not match current version '2024-09-10T09:11:14.0709070Z-10210-0'
   at Microsoft.CodeAnalysis.LanguageServer.Handler.CodeLens.CodeLensResolveHandler.HandleRequestAsync(CodeLens request, RequestContext context, CancellationToken cancellationToken) in /_/src/LanguageServer/Protocol/Handler/CodeLens/CodeLensResolveHandler.cs:line 55
   at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`1.StartRequestAsync[TRequest,TResponse](TRequest request, TRequestContext context, IMethodHandler handler, String language, CancellationToken cancellationToken)
[Warn  - 11:11:14] [LanguageServerHost] Ignoring diagnostics request for untracked document: file:///Users/jonatannyqvist/Coding/myApp/backend/Models/Server/Question.cs
ivanreyes30 commented 1 month ago

In the meantime, this is what I did. https://github.com/microsoft/vscode-dotnettools/issues/1451#issuecomment-2340175632

phil-allen-msft commented 1 month ago

Looks like a duplicate of https://github.com/dotnet/vscode-csharp/issues/7514