Vscode-powershell: Hitting F5 while powershell session is still initializing breaks debugger until vscode restart

Created on 29 Mar 2017  Â·  7Comments  Â·  Source: PowerShell/vscode-powershell

System Details

  • Operating system name and version: Windows 10 Enterprise
  • VS Code version:
  • PowerShell extension version: 1.10.2
  • Output from $PSVersionTable:
Importing Visual Studio Tools..
Loading Visual Studio Command Line Tools...
Loading personal and system profiles took 2584ms.
PS ↑ [christopher.mcgrath] | C:\WINDOWS\system32>
PS ↑ [christopher.mcgrath] | C:\WINDOWS\system32> code -v
1.10.2
8076a19fdcab7e1fc1707952d652f0bb6c6db331
PS ↑ [christopher.mcgrath] | C:\WINDOWS\system32> $pseditor.EditorServicesVersion
PS ↑ [christopher.mcgrath] | C:\WINDOWS\system32> code --list-extensions --show-versions
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
PS ↑ [christopher.mcgrath] | C:\WINDOWS\system32> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.14393.953
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14393.953
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Issue Description

If you are too fast hitting the F5 key after resetting a powershell session via command palette or on initial vscode startup the debugger craps out completely and can not start a debug session (at least via F5) until a full restart of vscode then it works fine again

Attached Logs

vscode-powershell.log.txt
EditorServices.log.txt

Area-Debugging Issue-Bug

Most helpful comment

Yeah, it's possible there's a conflict there. I've been seeing a stack trace like that more often now too. I've got an idea for how to fix it, will give it a shot this morning.

All 7 comments

Thanks for the report Chris! I'll look into it.

I hit this several times while testing the alternate-cwd branch. Was moving a bit too fast and the debugger wedges. One way it wedges is this:

$exception  {"A pipeline is already running. Concurrent SessionStateProxy method calls are not allowed."}   System.Management.Automation.PSInvalidOperationException

   at System.Management.Automation.Runspaces.RunspaceBase.DoConcurrentCheckAndMarkSessionStateProxyCallInProgress()
   at System.Management.Automation.Runspaces.RunspaceBase.get_PathIntrinsics()
   at Microsoft.PowerShell.EditorServices.PowerShellContext.SetWorkingDirectory(String path)
   at Microsoft.PowerShell.EditorServices.Protocol.Server.DebugAdapter.<HandleLaunchRequest>d__21.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<DispatchMessage>d__33.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<ListenForMessages>d__32.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at Microsoft.PowerShell.EditorServices.Utility.AsyncContext.Start(Func`1 asyncMainFunc)
   at Microsoft.PowerShell.EditorServices.Utility.AsyncContextThread.<>c__DisplayClass4_0.<Run>b__0()
   at System.Threading.Tasks.Task.Execute()

Is it possible we are attempting to execute PowerShell as part of debug launch when the console is still processing profiles and such?

Yeah, it's possible there's a conflict there. I've been seeing a stack trace like that more often now too. I've got an idea for how to fix it, will give it a shot this morning.

since the vscode update today i am getting this periodically as well in the terminal

Caught error while waiting for EditorServicesHost to complete:
One or more errors occurred.
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.ProtocolEndpoint.WaitForExit()
   at CallSite.Target(Closure , CallSite , Object )
One or more errors occurred.

Unable to cast object of type 'System.Management.Automation.ErrorRecord' to type 'System.Management.Automation.CommandCompletion'.
   at System.Linq.Enumerable.<CastIterator>d__94`1.MoveNext()
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
   at Microsoft.PowerShell.EditorServices.AstOperations.<GetCompletions>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.PowerShell.EditorServices.LanguageService.<GetCompletionsInFile>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.PowerShell.EditorServices.Protocol.Server.LanguageServer.<HandleCompletionRequest>d__36.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<DispatchMessage>d__33.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<ListenForMessages>d__32.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.PowerShell.EditorServices.Utility.AsyncContext.Start(Func`1 asyncMainFunc)
   at System.Threading.Tasks.Task.Execute()

Hey Chris, thanks for sending that. This is only happening when you try to get IntelliSense when the debugger is running. I'll fix this for the next patch update.

seems to be likely the culprit on the reemergence of the intellisense not working issue i reported last week as well

Was this page helpful?
0 / 5 - 0 ratings