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

Language service won't start sometimes #10021

Open
Peter-Juhasz opened this issue Mar 3, 2024 · 5 comments
Open

Language service won't start sometimes #10021

Peter-Juhasz opened this issue Mar 3, 2024 · 5 comments
Assignees

Comments

@Peter-Juhasz
Copy link

VS 17.10.0 P1

No outlining, no code completion. Although syntax highlighting and quick info seems to be working.

image

No logs in Razor logger output.

Reopening the file usually solves the issue. (The file was not copy-pasted.)

@maryamariyan
Copy link
Member

maryamariyan commented Jan 16, 2025

Thanks for your report @Peter-Juhasz. Could please you give us a bit more info to help us dig deeper?

  • Is this issue still popping up for you?
  • Is it happening with every Razor file or just certain ones?
  • What's the project type you're working on (e.g., Blazor, MVC, Razor Pages)?
  • Have you noticed any actions or a series of actions that make this issue happen?
  • Any error messages showing up in the Output window or the Error List window when you run into this?

Your answers will really help us get to the bottom of this. Thanks for your patience!

@Peter-Juhasz
Copy link
Author

Hi @maryamariyan,

Yes, it still does, usually when I first open a Razor file. Maybe larger files with ~500 lines are more prone to trigger the issue. But I can't reproduce it consistently. Reopening the file usually solves it.

The project type is Blazor Web Assembly with ~200 .razor pages/components (which is referenced by an ASP.NET Core project - with a few Razor files).

The next time I encounter this issue I will check the logs again and send it over.

But even with a clean run today morning (start VS, open Razor file) when Razor LS did start successfully, I can see some errors in the log:

[CLaSP] [09:53:16.9870107] [null]:                    System.InvalidOperationException: Start: (686,37) matches or exceeds SourceText boundary 637.                      
at Microsoft.AspNetCore.Razor.ThrowHelper.ThrowInvalidOperationException[T](String message)                      
at Microsoft.CodeAnalysis.Text.SourceTextExtensions.<GetTextSpan>g__GetAbsoluteIndex|24_0(SourceText text, Int32 line, Int32 character, String name)                      
at Microsoft.CodeAnalysis.Text.SourceTextExtensions.GetTextSpan(SourceText text, Int32 startLine, Int32 startCharacter, Int32 endLine, Int32 endCharacter)                      
at Microsoft.VisualStudio.LanguageServer.Protocol.VsLspExtensions.GetTextSpan(SourceText text, Range range)                      
at Microsoft.CodeAnalysis.Razor.Diagnostics.RazorTranslateDiagnosticsService.InCSharpLiteral(Diagnostic d, SourceText sourceText, RazorSyntaxTree syntaxTree)                      
at Microsoft.CodeAnalysis.Razor.Diagnostics.RazorTranslateDiagnosticsService.<>c__DisplayClass6_0.<FilterHTMLDiagnostics>b__0(Diagnostic d)                      
at System.Linq.Enumerable.WhereArrayIterator`1.MoveNext()                      
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)                      
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)                      
at Microsoft.CodeAnalysis.Razor.Diagnostics.RazorTranslateDiagnosticsService.<TranslateAsync>d__4.MoveNext()                   --- End of stack trace from previous location where exception was thrown ---                      
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()                      
at Microsoft.AspNetCore.Razor.LanguageServer.Diagnostics.DocumentPullDiagnosticsEndpoint.<HandleRequestAsync>d__10.MoveNext()                   --- End of stack trace from previous location where exception was thrown ---                      
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()                      
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)                      
at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`1.<StartRequestAsync>d__17`2.MoveNext()

I'm not sure they are related, I can move this to another issue if this is unrelated.

@Peter-Juhasz
Copy link
Author

@maryamariyan this is a demo from today morning:

20250118-0829-41.3585393.mp4

It is very strange, because:

  • C# seems to work fine
  • HTML/Razor syntax highlighting and quick info too
  • But HTML/Razor completion and outlining doesn't
  • Except one time Razor component completions somehow appear, but do not even after that try

Logs (although I had only Error level logs enabled):

[LSP][LanguageServer.Semantic.LSPCSharpSemanticTokensProvider] [09:29:53.7479013] We are behind the C# version which is surprising. Could be an old request that wasn't cancelled, but if not, expect most future requests to fail. We were wanting 27 but C# is at 28.

@maryamariyan
Copy link
Member

maryamariyan commented Jan 23, 2025

Thanks for all the info you've shared @Peter-Juhasz, it's super helpful! It look like we might have a bug to track down in the Razor language server.

On our end we're gonna try to replicate the issue and identify what's causing it. The intermittent nature of it makes it a bit tricky, but your notes are a great starting point.

In the meantime, there are a few things you could try that may help with some of the troubles you're experiencing and could help us understand the bug better as we work on this:

  • If possible, a minimal reproducible example would be fantastic (gives us the simplest environment to pinpoint what's the trigger)
  • Clear your VS cache by deleting the .vs folder in your solution directory. (removes any outdated or corrupt settings)
  • Make sure Visual Studio is up to date. (in case it's already fixed in a newer version)
  • Try running Visual Studio in safe mode by typing devenv /SafeMode in a developer command prompt. (if the bug still happens in this setting, it rules out that the problem is being caused by third-party extension)
  • Note any additional specific actions or sequences that trigger the problem. (thanks for all you shared already)

If any of these steps make a difference, do let us know. It'll help us understand the bug better.
Thanks again for your engagement and helping us improve this experience.

@Peter-Juhasz
Copy link
Author

  • Repro: open medium-large solution, search for Razor file, open file
  • Delete .vs folder: done
  • Latest update installed: done, VS 17.13.0 P4
  • Safe Mode: first time VS crashed completely, second time it starts with random error messages including "Access denied" printed in the Git Changes window. But there are no extensions enabled anyway.
  • Repro: open medium-large solution, search for Razor file, open file

This was the first try (note outlining worked this time, but Razor components were not recognized):

Image

Second try the same as usual:

Image

The very strange thing is that after around a whole minute, while writing this comment in another window, the list of completions popped over the window finally from VS:

Image

But it still didn't start, every new attempt takes like a minute to show up.

Neither errors/squiggles go away, only after around a minute:

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants