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

Preview extension crashes on mouse hover over a code block highlighted as a problem Pester #2135

Closed
Glober777 opened this issue Aug 14, 2019 · 15 comments
Labels
Area-Pester Bug: VS Code Bugs in VS Code itself.

Comments

@Glober777
Copy link

Issue Description

I am observing a crash of the Preview extension every time I hover over a block of code (inside a Pester test script) that is highlighted as a Problem (due to a test failure during the past run). As soon as I hover over, I can see a brief appearance of a little tool-tip showing the name of the failed test and a tiny message saying No quick fixes available and once it disappears, I receive a notification about termination of the PowerShell session.

Attached Logs

Diagnostics logs will be uploaded over an email.

Environment Information

Visual Studio Code

Name Version
Operating System Windows_NT x64 10.0.17763
VSCode 1.37.0
PowerShell Extension Version 2019.5.0

PowerShell Information

Name Value
PSVersion 5.1.17763.503
PSEdition Desktop
PSCompatibleVersions 1.0 2.0 3.0 4.0 5.0 5.1.17763.503
BuildVersion 10.0.17763.503
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Visual Studio Code Extensions

Visual Studio Code Extensions(Click to Expand)
Extension Author Version
azure-account ms-vscode 0.8.4
azure-pipelines ms-azure-devops 1.155.0
beautify HookyQR 1.5.0
code-settings-sync Shan 3.4.1
code-spell-checker streetsidesoftware 1.7.17
csharp ms-vscode 1.21.0
docs-article-templates docsmsft 0.2.7
docs-authoring-pack docsmsft 0.1.2
docs-markdown docsmsft 0.2.13
docs-preview docsmsft 0.3.25
docs-yaml docsmsft 0.2.3
ecdc mitchdenny 1.3.0
EditorConfig EditorConfig 0.13.0
gc-excelviewer GrapeCity 2.1.32
gitlens eamodio 9.9.3
live-html-previewer hdg 0.3.0
mssql ms-mssql 1.6.0
partial-diff ryu1kn 1.4.0
pomodoro-code odonno 0.2.1
powershell-preview ms-vscode 2019.5.0
team ms-vsts 1.149.2
theme-hackershaze Nuuf 2.0.1
todo-tree Gruntfuggly 0.0.140
vscode-hexdump slevesque 1.7.2
vscode-logicapps ms-azuretools 0.2.9
vscode-markdownlint DavidAnson 0.30.1
vscode-yaml redhat 0.4.1
xml DotJoshJohnson 2.5.0
@ghost ghost added the Needs: Triage Maintainer attention needed! label Aug 14, 2019
@SydneyhSmith
Copy link
Collaborator

@Glober777 from the logs it looks like you have a line with 1.7976931348623157E+308 characters and this is causing the crash...do you have any context on this? Is this behavior/crash happening with all your scripts or just a particular one?

@SydneyhSmith SydneyhSmith added Needs-Repro-Info and removed Needs: Triage Maintainer attention needed! labels Aug 16, 2019
@Glober777
Copy link
Author

Hey @SydneyhSmith, here's a sample project that repro the issue:
2135_Repro.zip

Just open it up in VSCode, and execute the default test Task for the project (so that the failed test would show up in the Problems list).

Just in case, I've also sent another set of logs collected from the repro project over an email.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Aug 19, 2019
@SydneyhSmith
Copy link
Collaborator

@Glober777 thanks for providing more information, we are still having trouble reproducing this...do you have any settings enabled related to PowerShell in VsCode?

@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Aug 20, 2019
@Glober777
Copy link
Author

@SydneyhSmith, the only PowerShell related settings that I have are:

{
   "powershell.developer.editorServicesLogLevel": "Diagnostic",
   "powershell.developer.featureFlags": [ "PSReadLine" ],
   "terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\WindowsPowerShell\\v1.0\\powershell.exe",
   "workbench.colorTheme": "PowerShell ISE"
}

Looks like the range for the codeAction follows the line with the 'It' statement, and the character number for the ending doesn't seem to depend on the test name.

Additionally, I've tested it out with the non-preview version of the extension and I'm experiencing the same issue. I wonder if I could get these extensions broken somehow. Uninstalling and re-installing doesn't help.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Aug 21, 2019
@SydneyhSmith
Copy link
Collaborator

I can see a brief appearance of a little tool-tip showing the name of the failed test and a tiny message saying No quick fixes available and once it disappears, I receive a notification about termination of the PowerShell session.

Thanks so much for all the information..you are right in that the codeAction seems to be what is causing the crash. The codeAction is coming from vscode so that is one reason we are having trouble tracking this issue down, since you seem to be able to consistently repro this to get more information on the code action could you please provide a GIF or screenshot of the above behavior?

@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Aug 22, 2019
@ghost
Copy link

ghost commented Aug 28, 2019

This issue is being closed as inactive, if this issue is still occurring it will be re-opened

@ghost ghost added the Resolution-Inactive Will close automatically. label Aug 28, 2019
@ghost ghost closed this as completed Aug 28, 2019
@Glober777
Copy link
Author

@SydneyhSmith, sorry for the delay, but I didn't have a chance to record it earlier. Here's the GIF:
2135_repro

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Aug 28, 2019
@Glober777
Copy link
Author

Can this be re-opened or shall I raise a new issue?

@SydneyhSmith
Copy link
Collaborator

@Glober777 thanks for the GIF--that is super helpful...one thing we noticed is that the "red squiggly" line (which seems to be triggering the crash) does not seem to be coming from the PowerShell extension...are you able to reproduce this error with only the PowerShell extension enabled? Thanks!

@SydneyhSmith SydneyhSmith removed Needs: Maintainer Attention Maintainer attention needed! Resolution-Inactive Will close automatically. labels Aug 29, 2019
@rkeithhill
Copy link
Contributor

rkeithhill commented Aug 30, 2019

I can repro this. It is another instance of the JSON serializer choking on a character position on the order of E+308. If I'm reading this right, this value is coming from VSCode as Number.MAX_VALUE. WTH?

2019-08-29 22:03:31.131 [VERBOSE] tid:17 in 'ReadMessage' C:\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageReader.cs: line 138
    Received Request 'textDocument/codeAction' with id 8
    
    {
      "jsonrpc": "2.0",
      "id": 8,
      "method": "textDocument/codeAction",
      "params": {
        "textDocument": {
          "uri": "file:///c%3A/Users/Keith/.vscode/extensions/ms-vscode.powershell-2019.5.0/examples/2135_Repro.Tests.ps1"
        },
        "range": {
          "start": {
            "line": 2,
            "character": 8
          },
          "end": {
            "line": 2,
            "character": 1.7976931348623157E+308
          }
        },
        "context": {
          "diagnostics": []
        }
      }
    }

2019-08-29 22:03:31.145 [ERROR] tid:40 in 'OnListenTaskCompleted' C:\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\MessageProtocol\ProtocolEndpoint.cs: line 391
    ProtocolEndpoint message loop terminated due to unhandled exception:
    
    System.AggregateException: One or more errors occurred. (Could not convert to integer: 1.79769313486232E+308. Path 'params.range.end.character', line 1, position 291.) ---> Newtonsoft.Json.JsonReaderException: Could not convert to integer: 1.79769313486232E+308. Path 'params.range.end.character', line 1, position 291. ---> System.OverflowException: Value was either too large or too small for an Int32.
       at System.Convert.ToInt32(Double value)
       at Newtonsoft.Json.JsonReader.ReadAsInt32()
       --- End of inner exception stack trace ---
       at Newtonsoft.Json.JsonReader.ReadAsInt32()
       at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
       at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
       at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
       at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
       at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
       at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
       at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
       at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
       at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
       at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
       at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
       at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer)
       at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType)
       at Newtonsoft.Json.Linq.JToken.ToObject[T]()
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<>c__DisplayClass4_0`4.<SetRequestHandler>b__0(Message requestMessage, MessageWriter messageWriter)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.DispatchMessage(Message messageToDispatch, MessageWriter messageWriter)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.ProtocolEndpoint.ListenForMessages(CancellationToken cancellationToken)
       at Microsoft.PowerShell.EditorServices.Utility.AsyncContext.Start(Func`1 asyncMainFunc, ILogger logger)
       at Microsoft.PowerShell.EditorServices.Utility.AsyncContextThread.<>c__DisplayClass4_0.<Run>b__0()
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
    --- End of stack trace from previous location where exception was thrown ---
       at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
       --- End of inner exception stack trace ---
    ---> (Inner Exception #0) Newtonsoft.Json.JsonReaderException: Could not convert to integer: 1.79769313486232E+308. Path 'params.range.end.character', line 1, position 291. ---> System.OverflowException: Value was either too large or too small for an Int32.
       at System.Convert.ToInt32(Double value)
       at Newtonsoft.Json.JsonReader.ReadAsInt32()
       --- End of inner exception stack trace ---
       at Newtonsoft.Json.JsonReader.ReadAsInt32()
       at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
       at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
       at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
       at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
       at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
       at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
       at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
       at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
       at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
       at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
       at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
       at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer)
       at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType)
       at Newtonsoft.Json.Linq.JToken.ToObject[T]()
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<>c__DisplayClass4_0`4.<SetRequestHandler>b__0(Message requestMessage, MessageWriter messageWriter)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.DispatchMessage(Message messageToDispatch, MessageWriter messageWriter)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.ProtocolEndpoint.ListenForMessages(CancellationToken cancellationToken)
       at Microsoft.PowerShell.EditorServices.Utility.AsyncContext.Start(Func`1 asyncMainFunc, ILogger logger)
       at Microsoft.PowerShell.EditorServices.Utility.AsyncContextThread.<>c__DisplayClass4_0.<Run>b__0()
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
    --- End of stack trace from previous location where exception was thrown ---
       at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)<---

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Aug 30, 2019
@SydneyhSmith
Copy link
Collaborator

@rkeithhill agreed that this is likely what is happening... still wondering though how you were able to repro this (was it using the same steps as provided)? and if you have any ideas as to where the red squiggly is coming from?

@rkeithhill
Copy link
Contributor

I opened up the examples folder, added a new file named 2135_Repro.Tests.ps1 with these contents:

Describe 'Repro for 2135 issue on GitHub' {
    It 'Test' -Test {
        3 % 2 | Should -BeExactly 0
    }
}

Then run the tests via the Run Tests code lens. When the error squiggle appears, hover over it.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Sep 5, 2019
@rjmholt
Copy link
Contributor

rjmholt commented Sep 5, 2019

I've got the file and managed to run the tests, but don't get a red squiggle. Is there some configuration or extension you've got enabling it @rkeithhill?

@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Sep 5, 2019
@rkeithhill
Copy link
Contributor

rkeithhill commented Sep 6, 2019

I no longer get the squiggle after updating to VSCode 1.38.0. Which is a problem because we should be highlighting the line of code where the Pester test fails. :-( OK, if you create this file in the root of the examples folder, you can then run the test task. That will create a red squiggle which, when you hover over it, will crash PSES. So now we have the original bug plus this new issue with not getting squiggles via the Pester code lens. :-(

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Sep 6, 2019
@SydneyhSmith SydneyhSmith added Bug: VS Code Bugs in VS Code itself. Area-Pester and removed Needs-Repro-Info Needs: Maintainer Attention Maintainer attention needed! labels Sep 12, 2019
@TylerLeonhardt
Copy link
Member

This shouldn't happen anymore. VS Code changed the new default max value to be in the range of Int32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Pester Bug: VS Code Bugs in VS Code itself.
Projects
None yet
Development

No branches or pull requests

5 participants