-
Notifications
You must be signed in to change notification settings - Fork 14
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] Error message "Request textDocument/semanticTokens/range failed" #722
Comments
@Kalkihe does this failure happen in only a specific file (what file extension does it have - .cs, .razor, etc)? If it only happens in a specific file, are you able to share the file contents (feel free to email me if you don't want to share here, my microsoft email is listed on my github profile). |
It happens on any .razor or .cs file is opened. I recently noticed that it happened when I was in comparison view of git and then checked out a different branch. Unfortunately I'm not able to share any file. But this should not be necessary, as it happened on multiple files. |
I've been unable to reproduce this myself. There is a known issue with similar symptoms in .razor files, but if you're seeing it in .cs files then its something else. Your stack trace looks very similar to the known .razor issue - especially because you mention you don't have any files longer than 200 lines (the error is inside the generated c# for the .razor file which can be very long). When you encounter it, can you provide details on the type of file, what steps you were doing immediately before the action (e.g. if it was a diff window, how exactly you got there, etc). |
Experiencing the same issue with
|
Same issue with .cshtml file.
|
It is obviously hard to remember all the steps that happened before I got to that error when it hits again. But I'll try this time because it just happened again. So I was working on some files (cs, .razor, json). After finishing my work on those files, I switched to the Source Control view to view the changes made on those files. I single-clicked every one of them and took a short view. This includes my index.razor file, which now is 297 lines long. Then I commited my work, but didn't push it. Then I closed the remaining comparison window and continued working. For this, I created a new .cs file and put some code in it. Then I switched back to my index.razor file and started editing the html code, when the error happened again. Now, on each action or scrolling within this file, the same error message appears over and over again. Logs of this incident are in the attachement. EDIT: Just had it again. Looked again (with single click) on the changes view on the .razor file, then switched back to the editing tab of that very file and the error occurred again. |
I have this error when editing .razor file, it's annoying and I cannot suppress this pop up in VS Code. |
This behavior is present whenever I edit anything in a razor template, used for a blazor wasm component. Version: 1.86.2 (user setup) C# Dev Kit version:
|
This issue seems to be specific to something. In older blazor projects, I don't have an issue. But in blazor file use v8.0, I get this error constantly. It is definitely some syntax that is throwing it for a loop. |
I also get this, editing a .razor page containing MudBlazor items in a Blazor Server app. Version: 1.86.2 (Universal) C# plugin is v2.19.13 (pre-release) Exception:
Left lower pop-ups text:
|
MacOS 14.3.1 Persists still, to replicate: have Blazor project, have a .razor file in it, all of it in a git repository, tracked. Open the project through devkit in vs code, make changes to the .razor file, save the file, open the diff view of it in VSCode, close the diff view, open in normal view, try to do any changes - the error pops up. Works every time. |
@artem-iron Did you have multiple .razor files open at once. A mix of .cs and razor. I have both situation and always get it as well. If you don't open the diff view, does is still happen? Side note, I start a component hierarchy the other day which forced me to put put a lot of my c# code that would have been in the .razor file into the code-behind and it dawned on my that I wasn't experience the issue as much. I have have no idea if the two things are related but 🤷 . |
@schaveyt I always use code behind documents, but I still experience this issue whenever I do anything in the razor template. Doesn't matter if I have the template document opened in the diff view or just in the regular edit one. |
@schaveyt for me it only happens when a diff view was opened at some point. So now i avoid opening that until i am ready to deal with reloading the vscode after. |
Oh god it's hard to believe the nightmare might finally be over. Thank you everyone |
OHHHHH GOSH FINALLY |
@ryzngard it doesn't solve yet :( Follow the code stack bellow
|
@douglas-wiliam thanks for testing. I'll keep looking. |
@douglas-wiliam can you file a separate issue? It looks like you're using a configuration that's different. Specifically omnisharp is enabled where the original issue was reported without. I still believe this issue is resolved and you're hitting a different one with a similar error message. |
@ryzngard in fact I was with the option Follow the code stack bellow: Info - 10:17:36 PM] [CLaSP] [StartContext] textDocument/semanticTokens/range
[Error - 10:17:36 PM] [CLaSP] [null]:
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'End (143,82) matches or exceeds SourceText boundary 1028.')
at Microsoft.CodeAnalysis.Razor.Workspaces.SourceTextExtensions.<GetTextSpan>g__GetAbsoluteIndex|11_0(Int32 line, Int32 character, SourceText sourceText, String argName) in /_/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/SourceTextExtensions.cs:line 287
at Microsoft.CodeAnalysis.Razor.Workspaces.SourceTextExtensions.GetTextSpan(SourceText sourceText, Int32 startLine, Int32 startCharacter, Int32 endLine, Int32 endCharacter) in /_/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/SourceTextExtensions.cs:line 273
at Microsoft.CodeAnalysis.Razor.Workspaces.LinePositionSpanExtensions.ToTextSpan(LinePositionSpan linePositionSpan, SourceText sourceText) in /_/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LinePositionSpanExtensions.cs:line 18
at Microsoft.CodeAnalysis.Razor.SemanticTokens.AbstractRazorSemanticTokensInfoService.GetSemanticTokensAsync(VersionedDocumentContext documentContext, LinePositionSpan span, Guid correlationId, Boolean colorBackground, CancellationToken cancellationToken) in /_/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/SemanticTokens/AbstractRazorSemanticTokensInfoService.cs:line 69
at Microsoft.CodeAnalysis.Razor.SemanticTokens.AbstractRazorSemanticTokensInfoService.GetSemanticTokensAsync(VersionedDocumentContext documentContext, LinePositionSpan span, Boolean colorBackground, Guid correlationId, CancellationToken cancellationToken) in /_/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/SemanticTokens/AbstractRazorSemanticTokensInfoService.cs:line 45
at Microsoft.AspNetCore.Razor.LanguageServer.Semantic.SemanticTokensRangeEndpoint.HandleRequestAsync(SemanticTokensRangeParams request, RazorRequestContext requestContext, CancellationToken cancellationToken) in /_/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Semantic/SemanticTokensRangeEndpoint.cs:line 54
at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`3.StartRequestAsync(TRequestContext context, IMethodHandler handler, CancellationToken cancellationToken)
[Error - 10:17:36 PM] Request textDocument/semanticTokens/range failed.
Message: Specified argument was out of the range of valid values. (Parameter 'End (143,82) matches or exceeds SourceText boundary 1028.')
Code: -32004
[object Object]
[Info - 10:17:36 PM] [CLaSP] [EndContext] textDocument/semanticTokens/range
[Info - 10:17:36 PM] [CLaSP] [EndContext] textDocument/inlayHint
[Info - 10:17:36 PM] [CLaSP] [EndContext] textDocument/inlayHint
[Info - 10:17:36 PM] [LSP][LanguageServer.Semantic.RazorSemanticTokensInfoService] Returned 291 semantic tokens for span (48,0)-(127,0) in review:/some-path-to-file/Detalhes.cshtml?{"path"%3A"Views%2FFile%2FPath%2FDetalhes.cshtml"%2C"commit"%3A"cd28ced196721687e9b0cde861afc67eba13b224"%2C"base"%3Atrue%2C"isOutdated"%3Afalse%2C"rootPath"%3A"%2Fhome%my-personal-directory%2FProjects%2Fsome-project"}.
[Info - 10:17:36 PM] [LSP][LanguageServer.Semantic.RazorSemanticTokensInfoService] Returned 298 semantic tokens for span (50,0)-(129,0) in file:///some-path-to-file/Detalhes.cshtml.
[Info - 10:17:36 PM] [CLaSP] [EndContext] textDocument/semanticTokens/range
[Info - 10:17:36 PM] [CLaSP] [EndContext] textDocument/semanticTokens/range
[Info - 10:17:36 PM] [CLaSP] [EndContext] textDocument/inlayHint
[Info - 10:17:36 PM] [CLaSP] [EndContext] textDocument/inlayHint
[Info - 10:17:36 PM] [LSP][LanguageServer.Semantic.RazorSemanticTokensInfoService] Returned 298 semantic tokens for span (50,0)-(129,0) in file:///some-path-to-file/Detalhes.cshtml.
[Info - 10:17:36 PM] [CLaSP] [EndContext] textDocument/semanticTokens/range
[Info - 10:17:37 PM] [CLaSP] [EndContext] textDocument/inlayHint
[Info - 10:17:37 PM] [CLaSP] [EndContext] textDocument/inlayHint
[Info - 10:17:37 PM] [CLaSP] [EndContext] textDocument/inlayHint
[Info - 10:17:37 PM] [CLaSP] [EndContext] textDocument/inlayHint
[Info - 10:17:37 PM] [LSP][LanguageServer.Semantic.RazorSemanticTokensInfoService] Returned 382 semantic tokens for span (61,0)-(141,90) in review:/some-path-to-file/Detalhes.cshtml?{"path"%3A"Views%2FFile%2FPath%2FDetalhes.cshtml"%2C"commit"%3A"cd28ced196721687e9b0cde861afc67eba13b224"%2C"base"%3Atrue%2C"isOutdated"%3Afalse%2C"rootPath"%3A"%2Fhome%my-personal-directory%2FProjects%2Fsome-project"}.
[Info - 10:17:37 PM] [CLaSP] [EndContext] textDocument/semanticTokens/range
[Info - 10:17:38 PM] [CLaSP] [EndContext] textDocument/inlayHint |
@douglas-wiliam I appreciate the extra info and apologize for the slight delay in response (I was on vacation 🏖️ ) Catching back up to this. Do you have a repro project I can use? I wasn't able to reproduce with the test projects I have. |
I am having the same problem on C# v2.39.29/VSCode 1.92.2/MacOS. Seems to affect all razor files and won't go away, making the extension less than usable. It used to happen before but couple of reloads would fix it. Now it appears to persist and is always broken. Curiously enough, the language server appears to always think that there should be 512 lines in any file; I think this should point at the possible culprit. Clearly, not all files have 512 lines. :-D Example errors: Request textDocument/semanticTokens/range failed. System.ArgumentException: Range={ Start={ Line=801, Character=21 }, End={ Line=801, Character=21 } }. text.Length=14693. text.Lines.Count=512 System.ArgumentException: Range={ Start={ Line=72, Character=0 }, End={ Line=1415, Character=22 } }. text.Length=14670. text.Lines.Count=512 System.ArgumentOutOfRangeException: The requested line number 1131 must be less than the number of lines 512. (Parameter 'Line') And so on. Full stack trace reported for one of such errors:
|
Reading through the thread makes it pretty clear, that the line count value for each file gets "aliased" somehow and language server starts thinking that all files should have the same line count from that point on. Moreover, we see that different people get different "wrong line counts" in their session which strongly smells of improperly initialised variable; the wrong value then persists for the duration of the session. To test the hypothesis I have restarted my VSCode and the value had indeed changed. Now it's 155 instead of 512: Error making textDocument/inlayHint request: Range={ Start={ Line=72, Character=0 }, End={ Line=245, Character=1 } }. text.Length=5025. text.Lines.Count=155 |
And more interesting behaviour:
|
ugh 🙄 so now I have to choose between unit tests not being discovered in the Preview version, or constant error spam in the Release version |
@AbhitejJohn fyi on the UT discovery comment. If known, lets try to hotfix the preview. |
Yep, I am seeing this a lot trying to stumble through the migration to FlatConfig. My experience, which as of late feels extensive, is that it usually indicates something wrong with config. It's a generally unhelpful error. Unsolvable without more information, and frequently used when there is no other obvious error to report. Wish I had better news! |
There is an issue in the release version with codelens in the diff editor causing the server to crash. Should be fixed in the latest prerelease version of the C# extension, or can workaround the issue by disabling |
Still relevant.. |
I'm still seeing this issue as well
…On Tue, Sep 17, 2024 at 5:58 AM Denis ***@***.***> wrote:
Still relevant..
—
Reply to this email directly, view it on GitHub
<#722 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA3EIIB2SIQW4ILZ7VY6JQLZXAKNHAVCNFSM6AAAAAA7MVGH3WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNJVGUYDKOBVGU>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Right now, razor support is totally broken. Moreover, it is broken consistently, on all platforms and installations both old and new. :-) |
I'm having the same issue running on macOS with VSCode and C# extension 2.45.25. Constant error popups from the C# extension while editing razor files. I see both razor/provideSemanticTokensRange failed with TypeError: Cannot read properties of undefined (reading 'data') and razor/inlayHint failed with Error: Range={ Start={ Line=62, Character=0 }, End={ Line=372, Character=0 } }. text.Length=13537. text.Lines.Count=359 |
How is this not a part of the September / October Iteration plan? This has been going on since before the beginning of the year. 10-20 times a day i have to restart VS Code because of this. Unreal that this is still a problem. |
I'm sorry you're still hitting this issue. There are many root causes to this problem. Some have been fixed, some are currently being worked on. This is high on my list for October to find a better user experience. |
Describe the Issue
This happens on a regular basis, mostly after using the comparison view from git on a C# file. The message "Request textDocument/semanticTokens/range failed" pops up in visual studio code. I can close it, but when scrolling through any C# file, it will just pop up again multiple times. This kind of makes vscode unusable until I restart it. Here are some logs:
Click to show logs
`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\\df844993"} received named pipe information from server attempting to connect client to server... client has connected to server [Info - 2:32:53 PM] [Program] Language server initialized [Info - 2:32:55 PM] [WorkspaceProjectFactoryService] Project D:\Coding\TOOMLE\TOOMLE.csproj loaded by C# Dev Kit [Error - 3:51:34 PM] [LanguageServerHost] System.ArgumentException: Range={ Start={ Line=526, Character=1 }, End={ Line=692, Character=0 } }. text.Length=18. text.Lines.Count=3 ---> System.ArgumentOutOfRangeException: The requested line number 526 must be less than the number of lines 3. (Parameter 'Line') at Microsoft.CodeAnalysis.Text.TextLineCollection.GetPosition(LinePosition position) in /_/src/Compilers/Core/Portable/Text/TextLineCollection.cs:line 67 at Microsoft.CodeAnalysis.Text.TextLineCollection.GetTextSpan(LinePositionSpan span) in /_/src/Compilers/Core/Portable/Text/TextLineCollection.cs:line 78 at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.RangeToTextSpan(Range range, SourceText text) in /_/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 298 --- End of inner exception stack trace --- at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.RangeToTextSpan(Range range, SourceText text) in /_/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 298 at Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens.SemanticTokensHelpers.ComputeSemanticTokensDataAsync(ClientCapabilities capabilities, Document document, Range[] ranges, ClassificationOptions options, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensHelpers.cs:line 103 at Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens.SemanticTokensHelpers.HandleRequestHelperAsync(IGlobalOptionService globalOptions, SemanticTokensRefreshQueue semanticTokensRefreshQueue, Range[] ranges, RequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensHelpers.cs:line 63 at Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens.SemanticTokensRangeHandler.HandleRequestAsync(SemanticTokensRangeParams request, RequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensRangeHandler.cs:line 47 at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`3.StartRequestAsync(TRequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 176 [Error - 3:51:34 PM] Request textDocument/semanticTokens/range failed. Message: Range={ Start={ Line=526, Character=1 }, End={ Line=692, Character=0 } }. text.Length=18. text.Lines.Count=3 Code: -32000 [object Object] [Error - 3:51:40 PM] [LanguageServerHost] System.ArgumentOutOfRangeException: The requested line number 663 must be less than the number of lines 4. (Parameter 'Line') at Microsoft.CodeAnalysis.Text.TextLineCollection.GetPosition(LinePosition position) in /_/src/Compilers/Core/Portable/Text/TextLineCollection.cs:line 67 at Microsoft.CodeAnalysis.LanguageServer.Extensions.GetPositionFromLinePositionAsync(TextDocument document, LinePosition linePosition, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Extensions/Extensions.cs:line 158 at Microsoft.CodeAnalysis.LanguageServer.Handler.CompletionHandler.HandleRequestAsync(CompletionParams request, RequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/Completion/CompletionHandler.cs:line 78 at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`3.StartRequestAsync(TRequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 176 [Error - 3:51:40 PM] [LanguageServerHost] System.ArgumentOutOfRangeException: The requested line number 663 must be less than the number of lines 4. (Parameter 'Line') at Microsoft.CodeAnalysis.Text.TextLineCollection.GetPosition(LinePosition position) in /_/src/Compilers/Core/Portable/Text/TextLineCollection.cs:line 67 at Microsoft.CodeAnalysis.LanguageServer.Extensions.GetPositionFromLinePositionAsync(TextDocument document, LinePosition linePosition, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Extensions/Extensions.cs:line 158 at Microsoft.CodeAnalysis.LanguageServer.Handler.DocumentHighlightsHandler.HandleRequestAsync(TextDocumentPositionParams request, RequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/Highlights/DocumentHighlightHandler.cs:line 68 at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`3.StartRequestAsync(TRequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 176 [Error - 3:51:40 PM] Request textDocument/documentHighlight failed. Message: The requested line number 663 must be less than the number of lines 4. (Parameter 'Line') Code: -32000 [object Object] `I had to shorten the log because it was too long. There are a lots of errors like this within seconds. I have to add that the files I have in my project are not longer than 200 lines. It seems like that line number is set in a completely wrong way.
Steps To Reproduce
No response
Expected Behavior
Not showing that error message
Environment Information
OS: Windows 10
Visual studio code 1.84.2 system setup
C# Dev Kit v1.0.14
The text was updated successfully, but these errors were encountered: