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] <Cannot work with project source controlled by "Perforce for VS Code" extension> #1475

Closed
jsyx1994 opened this issue Sep 18, 2024 · 7 comments
Labels
area-roslyn bug Something isn't working triaged The issue has been triaged
Milestone

Comments

@jsyx1994
Copy link

jsyx1994 commented Sep 18, 2024

Describe the Issue

When enable the extention plugin "Perforce for VS Code", the total function will not work and it says:

[stdout] {"pipeName":"\\\\.\\pipe\\6801cf8c"}
received named pipe information from server
attempting to connect client to server...
client has connected to server
[Info  - 10:43:39 AM] [Program] Language server initialized
[Error - 10:43:40 AM] [LanguageServerHost] System.UriFormatException: Invalid URI: The hostname could not be parsed.
   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions)
   at System.Uri..ctor(String uriString)
   at Roslyn.LanguageServer.Protocol.DocumentUriConverter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options) in /_/src/LanguageServer/Protocol/Protocol/Converters/DocumentUriConverter.cs:line 17
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
   at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)
   at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
   at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)
   at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 utf8Json, JsonTypeInfo`1 jsonTypeInfo, Nullable`1 actualByteCount)
   at System.Text.Json.JsonSerializer.Deserialize[TValue](JsonElement element, JsonSerializerOptions options)
   at Microsoft.CommonLanguageServerProtocol.Framework.SystemTextJsonLanguageServer`1.DeserializeRequest[TRequest](Object serializedRequest, RequestHandlerMetadata metadata) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/SystemTextJsonLanguageServer.cs:line 50
   at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`1.TryDeserializeRequest[TRequest](AbstractLanguageServer`1 languageServer, RequestHandlerMetadata requestHandlerMetadata, Boolean isMutating, TRequest& request) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 117
[Error - 10:43:40 AM] [LanguageServerHost] System.UriFormatException: Invalid URI: The hostname could not be parsed.
   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions)
   at System.Uri..ctor(String uriString)
   at Roslyn.LanguageServer.Protocol.DocumentUriConverter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options) in /_/src/LanguageServer/Protocol/Protocol/Converters/DocumentUriConverter.cs:line 17
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
   at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)
   at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
   at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)
   at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 utf8Json, JsonTypeInfo`1 jsonTypeInfo, Nullable`1 actualByteCount)
   at System.Text.Json.JsonSerializer.Deserialize[TValue](JsonElement element, JsonSerializerOptions options)
   at Microsoft.CommonLanguageServerProtocol.Framework.SystemTextJsonLanguageServer`1.DeserializeRequest[TRequest](Object serializedRequest, RequestHandlerMetadata metadata) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/SystemTextJsonLanguageServer.cs:line 50
   at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`1.TryDeserializeRequest[TRequest](AbstractLanguageServer`1 languageServer, RequestHandlerMetadata requestHandlerMetadata, Boolean isMutating, TRequest& request) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 117
--- End of stack trace from previous location ---
   at Microsoft.CommonLanguageServerProtocol.Framework.AbstractLanguageServer`1.DelegatingEntryPoint.InvokeAsync(IRequestExecutionQueue`1 queue, Object requestObject, ILspServices lspServices, CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/AbstractLanguageServer.cs:line 202
   at Microsoft.CommonLanguageServerProtocol.Framework.SystemTextJsonLanguageServer`1.SystemTextJsonDelegatingEntryPoint.ExecuteRequestAsync(Nullable`1 request, CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/SystemTextJsonLanguageServer.cs:line 88
   at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`1.CreateRequestContextAsync[TRequest](IMethodHandler handler, RequestHandlerMetadata requestHandlerMetadata, AbstractLanguageServer`1 languageServer, CancellationToken cancellationToken)
   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 319
   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  - 10:43:40 AM] Error processing queue, shutting down
[Error - 10:43:40 AM] Workspace diagnostic pull failed.
Canceled: Canceled
	at a.handleFailedRequest (c:\Users\zhentao.wang\.vscode\extensions\ms-dotnettools.csharp-2.45.25-win32-x64\dist\extension.js:2:2137527)
	at a.handleFailedRequest (c:\Users\zhentao.wang\.vscode\extensions\ms-dotnettools.csharp-2.45.25-win32-x64\dist\extension.js:2:1253271)
	at c:\Users\zhentao.wang\.vscode\extensions\ms-dotnettools.csharp-2.45.25-win32-x64\dist\extension.js:2:2174939
	at async g.pullWorkspaceAsync (c:\Users\zhentao.wang\.vscode\extensions\ms-dotnettools.csharp-2.45.25-win32-x64\dist\extension.js:2:2172247)
[Error - 10:43:40 AM] Workspace diagnostic pull failed.
Canceled: Canceled
	at a.handleFailedRequest (c:\Users\zhentao.wang\.vscode\extensions\ms-dotnettools.csharp-2.45.25-win32-x64\dist\extension.js:2:2137527)
	at a.handleFailedRequest (c:\Users\zhentao.wang\.vscode\extensions\ms-dotnettools.csharp-2.45.25-win32-x64\dist\extension.js:2:1253271)
	at c:\Users\zhentao.wang\.vscode\extensions\ms-dotnettools.csharp-2.45.25-win32-x64\dist\extension.js:2:2174939
	at runNextTicks (node:internal/process/task_queues:60:5)
	at process.processImmediate (node:internal/timers:449:9)
	at async g.pullWorkspaceAsync (c:\Users\zhentao.wang\.vscode\extensions\ms-dotnettools.csharp-2.45.25-win32-x64\dist\extension.js:2:2172247)
[Error - 10:43:40 AM] Workspace diagnostic pull failed.
Canceled: Canceled
	at a.handleFailedRequest (c:\Users\zhentao.wang\.vscode\extensions\ms-dotnettools.csharp-2.45.25-win32-x64\dist\extension.js:2:2137527)
	at a.handleFailedRequest (c:\Users\zhentao.wang\.vscode\extensions\ms-dotnettools.csharp-2.45.25-win32-x64\dist\extension.js:2:1253271)
	at c:\Users\zhentao.wang\.vscode\extensions\ms-dotnettools.csharp-2.45.25-win32-x64\dist\extension.js:2:2174939
	at runNextTicks (node:internal/process/task_queues:60:5)
	at process.processImmediate (node:internal/timers:449:9)
	at async g.pullWorkspaceAsync (c:\Users\zhentao.wang\.vscode\extensions\ms-dotnettools.csharp-2.45.25-win32-x64\dist\extension.js:2:2172247)
[Error - 10:43:40 AM] Request textDocument/diagnostic failed.
  Message: Server was requested to shut down.
  Code: -32000

Steps To Reproduce

  1. Download and Enable "Perforce for Vs Code"
  2. Open the c# project
  3. The error pops up and c# Dev kit cannot work

Expected Behavior

No response

Environment Information

Windows, C# Dev Kit v1.10.18, Perforce for VS Code v4.15.7

@jsyx1994 jsyx1994 added the bug Something isn't working label Sep 18, 2024
@AbhitejJohn
Copy link

Going by the stack, could this be related to either dotnet/vscode-csharp#7514 or dotnet/vscode-csharp#7399 @dibarbet ?

@mollstam
Copy link

mollstam commented Sep 19, 2024

I'm seeing the same issue, glad I found this.

Currently sitting with debugger attached to the language server, the string that is failing to parse as a URI for me is perforce://%23have/c:/Work/Code/Code.cs?command=print&p4Args=-q&rev=have&authority=null#have. And simply piping this into new Uri(..) will yield the same result.

Not sure why that %23 (#) is being put in there by vscode-perforce, will dig into it.

Edit: "in there" -> "in the hostname of the uri string"

@dibarbet
Copy link
Member

dibarbet commented Sep 20, 2024

See dotnet/vscode-csharp#6256 (comment)

Some of the the perforce URIs I believe are invalid - the host should not be pct encoded. On other ones, the URI is fine, but System.Uri blows up on it. Above linked comment has the details on the ones I found.

At least the incorrect URIs (with invalid host names) should be updated by the perforce extension. We use System.Uri all over the language server, so it isn't easy to work around this issue if it cannot parse them.

@mollstam
Copy link

I'll reach out to the vscode-perforce repo to figure out why they're putting the revision as the authority component. https://github.com/mjcrouch/vscode-perforce/blob/7bd13fd4e650fc98e86bf147d4e09968bbeaf6a9/src/PerforceUri.ts#L69

Do you know if the authority component has special significance for the language server or is the whole uri simply used as an identifier for the text document? Sorry if moot/lost question, I'm not deep into this. :-)

@mollstam
Copy link

mollstam commented Sep 20, 2024

Ah, here's a related issue in the extension repo. ✨

mjcrouch/vscode-perforce#260

@dibarbet
Copy link
Member

Do you know if the authority component has special significance for the language server or is the whole uri simply used as an identifier for the text document? Sorry if moot/lost question, I'm not deep into this. :-)

Apologies for the late reply - the authority isn't particularly important - just needs to be parseable by System.Uri.

@dibarbet
Copy link
Member

dibarbet commented Oct 7, 2024

transferred over to the C# extension side for tracking - dotnet/vscode-csharp#7638

@dibarbet dibarbet closed this as completed Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-roslyn bug Something isn't working triaged The issue has been triaged
Projects
None yet
Development

No branches or pull requests

4 participants