Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Project system ran into an unexpected problem #1470

Closed
mwkcoding opened this issue Sep 16, 2024 · 15 comments · Fixed by dotnet/vscode-csharp#7645
Closed

[BUG] Project system ran into an unexpected problem #1470

mwkcoding opened this issue Sep 16, 2024 · 15 comments · Fixed by dotnet/vscode-csharp#7645
Assignees
Labels
area-razor bug Something isn't working needs-more-info Needing more information, waiting on OP

Comments

@mwkcoding
Copy link

Describe the Issue

image
ProjectSystemServerFault_3500c59e-65a9-47b2-8922-9e02834f98f4.failure.txt

Steps To Reproduce

I'm not sure, it comes up every time I open my repo.

Expected Behavior

No notification?

Environment Information

Version: 1.93.1 (system setup)
Commit: 38c31bc77e0dd6ae88a4e9cc93428cc27a56ba40
Date: 2024-09-11T17:20:05.685Z
Electron: 30.4.0
ElectronBuildId: 10073054
Chromium: 124.0.6367.243
Node.js: 20.15.1
V8: 12.4.254.20-electron.0
OS: Windows_NT x64 10.0.22631
Extension: v1.10.18

@mwkcoding mwkcoding added the bug Something isn't working label Sep 16, 2024
@AbhitejJohn AbhitejJohn added the area-project Project load, Solution Explorer label Sep 16, 2024
@NathanVG
Copy link

I am having the same issue, error happens as soon as I open a project.

=====================
9/17/2024 9:50:48 AM
LimitedFunctionality
System.AggregateException: Project system data flow 'Workspace update handler 56128182' closed because of an exception: Object reference not set to an instance of an object.. (Object reference not set to an instance of an object.)
---> (Inner Exception #0) StreamJsonRpc.RemoteInvocationException: Object reference not set to an instance of an object.
   at StreamJsonRpc.JsonRpc.InvokeCoreAsync[TResult](RequestId id, String targetName, IReadOnlyList`1 arguments, IReadOnlyList`1 positionalArgumentDeclaredTypes, IReadOnlyDictionary`2 namedArgumentDeclaredTypes, CancellationToken cancellationToken, Boolean isParameterObject)
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Handlers.DynamicItemHandler.<>c__DisplayClass6_0.<<HandleProjectChangeAsync>g__ProcessAdditionsAsync|4>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Handlers.DynamicItemHandler.HandleProjectChangeAsync(IWorkspaceProject context, IComparable version, IProjectChangeDescription projectChange, ContextState state, ITelemetryOperation telemetryOperation, IManagedProjectDiagnosticOutputService logger)
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Handlers.DynamicItemHandler.HandleAsync(IWorkspaceProject context, IComparable version, IImmutableDictionary`2 projectChanges, ContextState state, ITelemetryOperation telemetryOperation, IManagedProjectDiagnosticOutputService logger)
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Workspace.<>c__DisplayClass43_1.<<OnEvaluationUpdateAsync>g__ProcessSourceItemsHandlersAsync|6>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Workspace.<>c__DisplayClass43_0.<<OnEvaluationUpdateAsync>g__ApplyProjectEvaluationAsync|2>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Workspace.<>c__DisplayClass46_1`1.<<OnProjectChangedAsync>g__ApplyInBatchAsync|1>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.Threading.ReentrantSemaphore.StackSemaphore.<>c__DisplayClass3_0.<<ExecuteAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.Threading.ReentrantSemaphore.StackSemaphore.ExecuteAsync(Func`1 operation, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.ProjectSystem.OnceInitializedOnceDisposedUnderLockAsync.ExecuteUnderLockCoreAsync(Func`2 action, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Workspace.OnEvaluationUpdateAsync(IProjectVersionedValue`1 evaluationUpdate)
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Workspace.<>c__DisplayClass42_0.<<OnWorkspaceUpdateAsync>g__ApplyUpdateWithinLockAsync|1>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Workspace.<>c__DisplayClass42_0.<<OnWorkspaceUpdateAsync>g__ApplyUpdateWithinLockAsync|1>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Workspace.<>c__DisplayClass42_0.<<OnWorkspaceUpdateAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.Threading.ReentrantSemaphore.StackSemaphore.<>c__DisplayClass3_0.<<ExecuteAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.Threading.ReentrantSemaphore.StackSemaphore.ExecuteAsync(Func`1 operation, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.ProjectSystem.OnceInitializedOnceDisposedUnderLockAsync.ExecuteUnderLockCoreAsync(Func`2 action, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.ProjectSystem.DataReceivingBlockSlim`1.ProcessInputQueueAsync(InputDataBuffer inputQueue)
<--- (Inner Exception #0) 
===================

@smitpatel smitpatel added area-roslyn and removed area-project Project load, Solution Explorer labels Sep 18, 2024
@mwkcoding
Copy link
Author

It might be causing the C#/.NET IntelliSense to not work properly. I have to restart vscode 2-5 times until the IntelliSense works properly.

@dibarbet
Copy link
Member

Two requests

  1. Could you post the C# output window logs?
  2. If you're willing, are you able to share the solution you're using? My email is dabarbet@microsoft.com if you'd prefer to share that way.

@tmeschter is there any way the project system side could log the details of the inner StreamJsonRpc.RemoteInvocation exception? That would hopefully give us a stack trace from the Roslyn side.

@mwkcoding
Copy link
Author

C# log:

Using dotnet configured on PATH
Dotnet path: C:\Program Files\dotnet\dotnet.exe
Activating C# + C# Dev Kit + C# IntelliCode...
waiting for named pipe information from server...
[stdout] {"pipeName":"\\\\.\\pipe\\29c20836"}
received named pipe information from server
attempting to connect client to server...
client has connected to server
[Info  - 9:06:46 AM] [Program] Language server initialized
[Info  - 9:07:18 AM] [WorkspaceProjectFactoryService] Project [REDACTED].csproj loaded by C# Dev Kit
... (same message goes for each individual project)

I'm not sure I can share my solution. But I can tell you it's a solution containing ~46 projects (WebJobs, Functions, Web Apps and a bunch of shared classes)

@smitpatel
Copy link
Member

@dibarbet - The extension logs contain details about JSON RPC errors. It is hard to say which file is but we have all logs, we can look through it and identify. It would contain which RPC call failed and whole stacktrace and error.

@mwkcoding - Please share content of extension logs folder for C# dev kit. You can find extension logs folder using command palette in VS Code. Once you open that you can see a folder with name ending in csdevkit. Content of that folder would be useful. You can send the zip for the folder to @dibarbet via email they provided above if you don't comfortable uploading here. Since this folder contains logs for whole session, please have a fresh session of VS Code to capture the logs when error happens.

@mwkcoding
Copy link
Author

@smitpatel @dibarbet I sent my logs folder zipped to the email provided.

@dibarbet
Copy link
Member

dibarbet commented Oct 1, 2024

Thanks got the logs!

@smitpatel I'm seeing a few different issues - it would be useful if you could identify what brokered service and process is being called for each. It looks like one of the null refs might be in the project system side?

StreamJsonRpc.ConnectionLostException

Numerous connection lost exceptions, these are the stack traces I saw

StreamJsonRpc.ConnectionLostException: The JSON-RPC connection with the remote party was lost before the request could complete.
   at StreamJsonRpc.JsonRpc.InvokeCoreAsync(JsonRpcRequest request, Type expectedResultType, CancellationToken cancellationToken)
   at StreamJsonRpc.JsonRpc.InvokeCoreAsync[TResult](RequestId id, String targetName, IReadOnlyList`1 arguments, IReadOnlyList`1 positionalArgumentDeclaredTypes, IReadOnlyDictionary`2 namedArgumentDeclaredTypes, CancellationToken cancellationToken, Boolean isParameterObject)
   at Microsoft.VisualStudio.ProjectSystem.VSCode.SolutionPathProvider.GetSolutionPathAsync(CancellationToken cancellationToken)
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Workspace.<>c__DisplayClass43_0.<<OnEvaluationUpdateAsync>g__ProcessInitialEvaluationDataAsync|1>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Workspace.<>c__DisplayClass43_0.<<OnEvaluationUpdateAsync>g__ProcessInitialEvaluationDataAsync|1>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Workspace.OnEvaluationUpdateAsync(IProjectVersionedValue`1 evaluationUpdate)
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Workspace.<>c__DisplayClass42_0.<<OnWorkspaceUpdateAsync>g__ApplyUpdateWithinLockAsync|1>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Workspace.<>c__DisplayClass42_0.<<OnWorkspaceUpdateAsync>g__ApplyUpdateWithinLockAsync|1>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Workspace.<>c__DisplayClass42_0.<<OnWorkspaceUpdateAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.Threading.ReentrantSemaphore.StackSemaphore.<>c__DisplayClass3_0.<<ExecuteAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
System.AggregateException: Project system data flow 'Workspace update handler 27446469' closed because of an exception: The JSON-RPC connection with the remote party was lost before the request could complete.. (The JSON-RPC connection with the remote party was lost before the request could complete.)
---> (Inner Exception #0) StreamJsonRpc.ConnectionLostException: The JSON-RPC connection with the remote party was lost before the request could complete.
   at StreamJsonRpc.JsonRpc.InvokeCoreAsync(JsonRpcRequest request, Type expectedResultType, CancellationToken cancellationToken)
   at StreamJsonRpc.JsonRpc.InvokeCoreAsync[TResult](RequestId id, String targetName, IReadOnlyList`1 arguments, IReadOnlyList`1 positionalArgumentDeclaredTypes, IReadOnlyDictionary`2 namedArgumentDeclaredTypes, CancellationToken cancellationToken, Boolean isParameterObject)
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Handlers.ProjectFilePathAndDisplayNameEvaluationHandler.HandleAsync(IWorkspaceProject context, ProjectConfiguration projectConfiguration, IComparable version, IProjectChangeDescription projectChange, ContextState state, ITelemetryOperation telemetryOperation, IManagedProjectDiagnosticOutputService logger)
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Workspace.<>c__DisplayClass43_1.<<OnEvaluationUpdateAsync>g__ProcessProjectEvaluationHandlersAsync|5>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Workspace.<>c__DisplayClass43_0.<<OnEvaluationUpdateAsync>g__ApplyProjectEvaluationAsync|2>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Workspace.<>c__DisplayClass46_1`1.<<OnProjectChangedAsync>g__ApplyInBatchAsync|1>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.Threading.ReentrantSemaphore.StackSemaphore.<>c__DisplayClass3_0.<<ExecuteAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.Threading.ReentrantSemaphore.StackSemaphore.ExecuteAsync(Func`1 operation, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.ProjectSystem.OnceInitializedOnceDisposedUnderLockAsync.ExecuteUnderLockCoreAsync(Func`2 action, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Workspace.OnEvaluationUpdateAsync(IProjectVersionedValue`1 evaluationUpdate)
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Workspace.<>c__DisplayClass42_0.<<OnWorkspaceUpdateAsync>g__ApplyUpdateWithinLockAsync|1>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Workspace.<>c__DisplayClass42_0.<<OnWorkspaceUpdateAsync>g__ApplyUpdateWithinLockAsync|1>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Workspace.<>c__DisplayClass42_0.<<OnWorkspaceUpdateAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.Threading.ReentrantSemaphore.StackSemaphore.<>c__DisplayClass3_0.<<ExecuteAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.Threading.ReentrantSemaphore.StackSemaphore.ExecuteAsync(Func`1 operation, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.ProjectSystem.OnceInitializedOnceDisposedUnderLockAsync.ExecuteUnderLockCoreAsync(Func`2 action, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.ProjectSystem.DataReceivingBlockSlim`1.ProcessInputQueueAsync(InputDataBuffer inputQueue)
<--- (Inner Exception #0) 

Null reference

I'm also seeing a fair number of null reference exceptions. In one case I see this

System.AggregateException: One or more errors occurred. (Object reference not set to an instance of an object.)
---> (Inner Exception #0) System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.VisualStudio.ProjectSystem.Server.ProjectLaunchConfigurationService.<InitializeCoreAsync>g__ActionBlockCallback|25_0(IProjectVersionedValue`1 data)
   at Microsoft.VisualStudio.ProjectSystem.ActionBlockSlimSync`1.ProcessInputAsync(TInput input)
   at Microsoft.VisualStudio.ProjectSystem.DataReceivingBlockSlim`1.ProcessInputQueueAsync(InputDataBuffer inputQueue)
<--- (Inner Exception #0) 

the rest I mostly see

System.AggregateException: Project system data flow 'Workspace update handler 61249327' closed because of an exception: Object reference not set to an instance of an object.. (Object reference not set to an instance of an object.)
---> (Inner Exception #0) StreamJsonRpc.RemoteInvocationException: Object reference not set to an instance of an object.
   at StreamJsonRpc.JsonRpc.InvokeCoreAsync[TResult](RequestId id, String targetName, IReadOnlyList`1 arguments, IReadOnlyList`1 positionalArgumentDeclaredTypes, IReadOnlyDictionary`2 namedArgumentDeclaredTypes, CancellationToken cancellationToken, Boolean isParameterObject)
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Handlers.DynamicItemHandler.<>c__DisplayClass6_0.<<HandleProjectChangeAsync>g__ProcessAdditionsAsync|4>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Handlers.DynamicItemHandler.HandleProjectChangeAsync(IWorkspaceProject context, IComparable version, IProjectChangeDescription projectChange, ContextState state, ITelemetryOperation telemetryOperation, IManagedProjectDiagnosticOutputService logger)
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Handlers.DynamicItemHandler.HandleAsync(IWorkspaceProject context, IComparable version, IImmutableDictionary`2 projectChanges, ContextState state, ITelemetryOperation telemetryOperation, IManagedProjectDiagnosticOutputService logger)
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Workspace.<>c__DisplayClass43_1.<<OnEvaluationUpdateAsync>g__ProcessSourceItemsHandlersAsync|6>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Workspace.<>c__DisplayClass43_0.<<OnEvaluationUpdateAsync>g__ApplyProjectEvaluationAsync|2>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Workspace.<>c__DisplayClass46_1`1.<<OnProjectChangedAsync>g__ApplyInBatchAsync|1>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.Threading.ReentrantSemaphore.StackSemaphore.<>c__DisplayClass3_0.<<ExecuteAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.Threading.ReentrantSemaphore.StackSemaphore.ExecuteAsync(Func`1 operation, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.ProjectSystem.OnceInitializedOnceDisposedUnderLockAsync.ExecuteUnderLockCoreAsync(Func`2 action, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Workspace.OnEvaluationUpdateAsync(IProjectVersionedValue`1 evaluationUpdate)
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Workspace.<>c__DisplayClass42_0.<<OnWorkspaceUpdateAsync>g__ApplyUpdateWithinLockAsync|1>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Workspace.<>c__DisplayClass42_0.<<OnWorkspaceUpdateAsync>g__ApplyUpdateWithinLockAsync|1>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Workspace.<>c__DisplayClass42_0.<<OnWorkspaceUpdateAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.Threading.ReentrantSemaphore.StackSemaphore.<>c__DisplayClass3_0.<<ExecuteAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.Threading.ReentrantSemaphore.StackSemaphore.ExecuteAsync(Func`1 operation, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.ProjectSystem.OnceInitializedOnceDisposedUnderLockAsync.ExecuteUnderLockCoreAsync(Func`2 action, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.ProjectSystem.DataReceivingBlockSlim`1.ProcessInputQueueAsync(InputDataBuffer inputQueue)
<--- (Inner Exception #0) 

@NathanVG
Copy link

NathanVG commented Oct 2, 2024

Everything was (kind of) working for me for a while but this error is popping up once again.

Honestly in combination with #722 this is getting rediculous. It's nearly a year now that a microsoft plugin for a microsoft language in a microsoft editor has been close to unusable.

=====================
10/2/2024 3:56:17 PM
LimitedFunctionality
System.AggregateException: Project system data flow 'Workspace update handler 48963094' closed because of an exception: Object reference not set to an instance of an object.. (Object reference not set to an instance of an object.)
---> (Inner Exception #0) StreamJsonRpc.RemoteInvocationException: Object reference not set to an instance of an object.
   at StreamJsonRpc.JsonRpc.InvokeCoreAsync[TResult](RequestId id, String targetName, IReadOnlyList`1 arguments, IReadOnlyList`1 positionalArgumentDeclaredTypes, IReadOnlyDictionary`2 namedArgumentDeclaredTypes, CancellationToken cancellationToken, Boolean isParameterObject)
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Handlers.DynamicItemHandler.<>c__DisplayClass6_0.<<HandleProjectChangeAsync>g__ProcessAdditionsAsync|4>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Handlers.DynamicItemHandler.HandleProjectChangeAsync(IWorkspaceProject context, IComparable version, IProjectChangeDescription projectChange, ContextState state, ITelemetryOperation telemetryOperation, IManagedProjectDiagnosticOutputService logger)
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Handlers.DynamicItemHandler.HandleAsync(IWorkspaceProject context, IComparable version, IImmutableDictionary`2 projectChanges, ContextState state, ITelemetryOperation telemetryOperation, IManagedProjectDiagnosticOutputService logger)
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Workspace.<>c__DisplayClass43_1.<<OnEvaluationUpdateAsync>g__ProcessSourceItemsHandlersAsync|6>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Workspace.<>c__DisplayClass43_0.<<OnEvaluationUpdateAsync>g__ApplyProjectEvaluationAsync|2>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Workspace.<>c__DisplayClass46_1`1.<<OnProjectChangedAsync>g__ApplyInBatchAsync|1>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.Threading.ReentrantSemaphore.StackSemaphore.<>c__DisplayClass3_0.<<ExecuteAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.Threading.ReentrantSemaphore.StackSemaphore.ExecuteAsync(Func`1 operation, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.ProjectSystem.OnceInitializedOnceDisposedUnderLockAsync.ExecuteUnderLockCoreAsync(Func`2 action, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Workspace.OnEvaluationUpdateAsync(IProjectVersionedValue`1 evaluationUpdate)
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Workspace.<>c__DisplayClass42_0.<<OnWorkspaceUpdateAsync>g__ApplyUpdateWithinLockAsync|1>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Workspace.<>c__DisplayClass42_0.<<OnWorkspaceUpdateAsync>g__ApplyUpdateWithinLockAsync|1>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.ProjectSystem.VSCode.LanguageServices.Workspace.<>c__DisplayClass42_0.<<OnWorkspaceUpdateAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.Threading.ReentrantSemaphore.StackSemaphore.<>c__DisplayClass3_0.<<ExecuteAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.VisualStudio.Threading.ReentrantSemaphore.StackSemaphore.ExecuteAsync(Func`1 operation, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.ProjectSystem.OnceInitializedOnceDisposedUnderLockAsync.ExecuteUnderLockCoreAsync(Func`2 action, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.ProjectSystem.DataReceivingBlockSlim`1.ProcessInputQueueAsync(InputDataBuffer inputQueue)
<--- (Inner Exception #0) 
===================

@dibarbet
Copy link
Member

dibarbet commented Oct 3, 2024

Suspecting an issue with Razor projects here. If anyone has a project they can consistently reproduce it in and can share, please email me (dabarbet@microsoft.com).

We're working on some changes in parallel that will provide more details on what went wrong when it fails which should be in an upcoming prerelease.

@dibarbet
Copy link
Member

dibarbet commented Oct 8, 2024

Using #1410 I was able to get a consistent repro. However I don't think it is the only way to hit this issue.

  1. Create a new folder, inside the folder create an aspire app (with sln) inside a folder and a blazor app inside a different folder, e.g.
    image
  2. In VSCode open the aspire folder only and wait for the aspire sln to load
    image
  3. In sln explorer, right click add existing project and add the blazor app from the folder above.

Note the following exception (requires latest preview 2.51 changes)

[Error - 12:17:25 PM] [Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.WorkspaceProject] Error applying project system update. System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.RazorDynamicFileInfoProvider.GetDynamicFileInfoAsync(ProjectId projectId, String projectFilePath, String filePath, CancellationToken cancellationToken) in C:\Users\dabarbet\source\repos\roslyn\src\LanguageServer\Microsoft.CodeAnalysis.LanguageServer\HostWorkspace\RazorDynamicFileInfoProvider.cs:line 74
   at Roslyn.Utilities.TaskExtensions.WaitAndGetResult_CanCallOnBackground[T](Task`1 task, CancellationToken cancellationToken) in C:\Users\dabarbet\source\repos\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\TaskExtensions.cs:line 56
   at Microsoft.CodeAnalysis.Workspaces.ProjectSystem.ProjectSystemProject.AddDynamicSourceFile(String dynamicFilePath, ImmutableArray`1 folders) in C:\Users\dabarbet\source\repos\roslyn\src\Workspaces\Core\Portable\Workspace\ProjectSystem\ProjectSystemProject.cs:line 896
   at Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.WorkspaceProject.<>c__DisplayClass9_0.<AddDynamicFilesAsync>b__0() in C:\Users\dabarbet\source\repos\roslyn\src\LanguageServer\Microsoft.CodeAnalysis.LanguageServer\HostWorkspace\WorkspaceProject.cs:line 71
   at Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.WorkspaceProject.RunAndReportNFWAsync(Action action, CancellationToken cancellationToken) in C:\Users\dabarbet\source\repos\roslyn\src\LanguageServer\Microsoft.CodeAnalysis.LanguageServer\HostWorkspace\WorkspaceProject.cs:line 224
   at Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.WorkspaceProject.RunAndReportNFWAsync(Action action, CancellationToken cancellationToken) in C:\Users\dabarbet\source\repos\roslyn\src\LanguageServer\Microsoft.CodeAnalysis.LanguageServer\HostWorkspace\WorkspaceProject.cs:line 224

It looks like Razor is not returning a C# document - https://github.com/dotnet/roslyn/blob/main/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/RazorDynamicFileInfoProvider.cs#L74

@phil-allen-msft @ryzngard FYI - we have a number of reports of this issue.

@raurfang
Copy link

raurfang commented Oct 8, 2024

We are also hitting the issue for the past few weeks.
Narrowed it down to a workspace looking more or less like this:

Workspace root
- backend
  - dotnet-razor-project
- frontend
  - js-project-A
    - node_modules
  - js-project-B
    - node_modules
  - ...
- node_modules

The JS projects reference a lot of packages and have big node_modules folders. They are using pnpm for package management.

  • Opening the <root>/backend folder in VS Code does not trigger the issue.
  • Opening the workspace <root> triggers the issue.
  • Removing /frontend/*/node_modules folders stops the issue.
  • Removing some /frontend/*/node_modules also stops the issue, but there is no rule which folders or files cause it

Rolling back the VS Code C# extension to version 2.41.26 or older also fixes the issue.

@ryzngard
Copy link
Member

ryzngard commented Oct 9, 2024

We are also hitting the issue for the past few weeks. Narrowed it down to a workspace looking more or less like this:

Workspace root
- backend
  - dotnet-razor-project
- frontend
  - js-project-A
    - node_modules
  - js-project-B
    - node_modules
  - ...
- node_modules

The JS projects reference a lot of packages and have big node_modules folders. They are using pnpm for package management.

  • Opening the <root>/backend folder in VS Code does not trigger the issue.
  • Opening the workspace <root> triggers the issue.
  • Removing /frontend/*/node_modules folders stops the issue.
  • Removing some /frontend/*/node_modules also stops the issue, but there is no rule which folders or files cause it

Rolling back the VS Code C# extension to version 2.41.26 or older also fixes the issue.

Thanks for this information. For the backend, does it include razor/cshtml files or just aspnetcore? If possible can you share a repro? If not possible to share, can you test with the vsix built in https://dev.azure.com/dnceng-public/cbb18261-c48f-4abb-8651-8cdcb5474649/_build/results?buildId=833689 ? That will help us know if the targeted fix spans to your scenario as well. Just looking at your information I would guess not, but I very much could be missing something.

@raurfang
Copy link

raurfang commented Oct 9, 2024

Rolling back the VS Code C# extension to version 2.41.26 or older also fixes the issue.

Thanks for this information. For the backend, does it include razor/cshtml files or just aspnetcore? If possible can you share a repro? If not possible to share, can you test with the vsix built in https://dev.azure.com/dnceng-public/cbb18261-c48f-4abb-8651-8cdcb5474649/_build/results?buildId=833689 ? That will help us know if the targeted fix spans to your scenario as well. Just looking at your information I would guess not, but I very much could be missing something.

Yes, the backend includes razor and cshtml files. I wasn't able to get reliable minimal reproduction steps, but the VSIX build seems to have helped!
It did take a lot of time to process the projects, but loaded them without the issue showing up, and all features seem to be working 👍

@ryzngard
Copy link
Member

ryzngard commented Oct 9, 2024

Great, Thank you @raurfang! Hopefully we'll have this available in release soon

@dibarbet
Copy link
Member

dibarbet commented Oct 16, 2024

The fix should be available in either 2.50.27 (release) or 2.52.24 (prerelease) of the C# extension

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-razor bug Something isn't working needs-more-info Needing more information, waiting on OP
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants