Skip to content

While typing in a file, NullReferenceException in ReferencesCodeLensProvider hangs language server #857

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

Closed
daviwil opened this issue Jun 10, 2017 · 3 comments
Labels
Area-Pester Issue-Bug A bug to squash.
Milestone

Comments

@daviwil
Copy link
Contributor

daviwil commented Jun 10, 2017

Need a general way to catch exceptions coming from feature providers so that they don't take down the language server when they misbehave.

    System.AggregateException: One or more errors occurred. ---> System.NullReferenceException: Object reference not set to an instance of an object.
       at Microsoft.PowerShell.EditorServices.CodeLenses.ReferencesCodeLensProvider.<ResolveCodeLensAsync>d__4.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.PowerShell.EditorServices.CodeLenses.CodeLensFeature.<HandleCodeLensResolveRequest>d__9.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.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<DispatchMessage>d__7.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.PowerShell.EditorServices.Protocol.MessageProtocol.ProtocolEndpoint.<ListenForMessages>d__36.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.PowerShell.EditorServices.Utility.AsyncContext.Start(Func`1 asyncMainFunc, ILogger logger)
       at System.Threading.Tasks.Task.Execute()
@daviwil daviwil added Area-Pester Issue-Bug A bug to squash. labels Jun 10, 2017
@daviwil daviwil added this to the June 2017 milestone Jun 10, 2017
@daviwil daviwil modified the milestones: June 2017, 1.3.2 Jun 11, 2017
@mattmcnabb
Copy link
Contributor

I'm seeing an issue where the Pester CodeLenses disappear from the document. Assuming it's due to this same issue, correct?

@daviwil
Copy link
Contributor Author

daviwil commented Jun 11, 2017

When the Pester lenses disappear do you see any exception in the logs?

@mattmcnabb
Copy link
Contributor

It appears to be the same one posted here. Tough to get an exact timestamp correlation, but it looks like the only significant error I see. There are a few other errors, but they appear to be happening around startup:

6/11/2017 1:36:47 PM [ERROR] - Method "DispatchMessage" at line 147 of C:\projects\powershelleditorservices\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageDispatcher.cs

    MessageDispatcher: No handler registered for Event type 'initialized'

6/11/2017 1:36:47 PM [ERROR] - Method "DispatchMessage" at line 147 of C:\projects\powershelleditorservices\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageDispatcher.cs

    MessageDispatcher: No handler registered for Event type '$/setTraceNotification'

6/11/2017 1:37:04 PM [ERROR] - Method "ListenForMessages" at line 344 of C:\projects\powershelleditorservices\src\PowerShellEditorServices.Protocol\MessageProtocol\ProtocolEndpoint.cs

    Stream terminated unexpectedly, ending MessageDispatcher loop
    
    Exception: IOException
    Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.

daviwil added a commit to daviwil/PowerShellEditorServices that referenced this issue Jun 12, 2017
This change fixes an issue where a null case isn't being handled
gracefully in the ReferencesCodeLensProvider when resolving a CodeLens
while the user is typing out a new function defintion or doing anything
else that causes the code to change like formatting the script.

Resolves PowerShell/vscode-powershell#857
Resolves PowerShell/vscode-powershell#855
daviwil added a commit to daviwil/PowerShellEditorServices that referenced this issue Jun 12, 2017
This change fixes an issue where a null case isn't being handled
gracefully in the ReferencesCodeLensProvider when resolving a CodeLens
while the user is typing out a new function defintion or doing anything
else that causes the code to change like formatting the script.

Resolves PowerShell/vscode-powershell#857
Resolves PowerShell/vscode-powershell#855
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Pester Issue-Bug A bug to squash.
Projects
None yet
Development

No branches or pull requests

2 participants