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

Hitting F5 while powershell session is still initializing breaks debugger until vscode restart #632

Closed
clmcgrath opened this issue Mar 29, 2017 · 7 comments
Labels
Milestone

Comments

@clmcgrath
Copy link

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
Andreabbondanza.ignoregit@1.0.0
cdsama.tortoise-svn-for-vscode@0.1.1
codezombiech.gitignore@0.5.0
Compulim.vscode-mocha@0.1.1
cspotcode.vscode-mocha-latte@0.2.0
dcortes92.FreeMarker@0.0.8
DotJoshJohnson.xml@1.7.0
eg2.vscode-npm-script@0.1.8
fantasytyx.tortoise-svn@0.1.1
felipecaputo.git-project-manager@1.2.1
formulahendry.code-runner@0.6.15
gep13.chocolatey-vscode@0.2.2
Kipters.codeshell@0.2.2
MattiasPernhult.vscode-todo@0.8.0
mbinic.tgit-cmds@1.0.0
ms-vscode.csharp@1.8.0
ms-vscode.PowerShell@0.11.0
qub.qub-msbuild@0.6.3
remcoros.startanyshell@0.3.1
robertohuertasm.vscode-icons@7.4.0
samverschueren.yo@0.9.3
wayou.vscode-todo-highlight@0.4.12
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

@clmcgrath clmcgrath changed the title Hitting F5 while powershell session is still breaks debugger until restart Hitting F5 while powershell session is still initializing breaks debugger until vscode restart Mar 30, 2017
@daviwil
Copy link
Contributor

daviwil commented Apr 2, 2017

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

@daviwil daviwil added Area-Debugging Issue-Bug A bug to squash. labels Apr 2, 2017
@daviwil daviwil added this to the Next Patch Update milestone Apr 2, 2017
@rkeithhill
Copy link
Contributor

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?

@daviwil
Copy link
Contributor

daviwil commented Apr 6, 2017

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.

@daviwil daviwil modified the milestones: Next Patch Update, Next Feature Update Apr 6, 2017
@clmcgrath
Copy link
Author

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()

@daviwil
Copy link
Contributor

daviwil commented Apr 6, 2017

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.

@daviwil
Copy link
Contributor

daviwil commented Apr 6, 2017

Tracking it with this issue: PowerShell/PowerShellEditorServices#427

@clmcgrath
Copy link
Author

clmcgrath commented Apr 6, 2017

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

daviwil added a commit to daviwil/PowerShellEditorServices that referenced this issue Apr 7, 2017
This change fixes a hang that occurs when the user starts the debugger
right when the PowerShell session is still initializing.  This is caused
by a call to PowerShellContext.SetWorkingDirectory which isn't
respecting the current state of the runspace.  The fix is to ask for a
RunspaceHandle to ensure that the runspace is free before attempting to
set the working directory.

Resolves PowerShell/vscode-powershell#632
daviwil added a commit to daviwil/PowerShellEditorServices that referenced this issue Apr 7, 2017
This change fixes a hang that occurs when the user starts the debugger
right when the PowerShell session is still initializing.  This is caused
by a call to PowerShellContext.SetWorkingDirectory which isn't
respecting the current state of the runspace.  The fix is to ask for a
RunspaceHandle to ensure that the runspace is free before attempting to
set the working directory.

Resolves PowerShell/vscode-powershell#632
@daviwil daviwil modified the milestones: 0.12.2, April 2017 Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants