When creating a background runspace and then attempting to debug it with Debug-Runspace causes the debugger to just continue through and never stop within the background runspace.
Steps to reproduce:
PS C:\src\universal> start-threadjob { Wait-Debugger; Get-Process }
Id Name PSJobTypeName State HasMoreData Location Command
-- ---- ------------- ----- ----------- -------- -------
1 Job1 ThreadJob NotStarted False PowerShell Wait-Debugger; Get-Proc…
PS C:\src\universal> get-runspace
Id Name ComputerName Type State Availability
-- ---- ------------ ---- ----- ------------
1 Runspace1 localhost Local Opened Available
4 Runspace4 localhost Local Opened Busy
6 Runspace6 localhost Local Opened Available
7 Runspace7 localhost Local Opened Available
8 Runspace8 localhost Local Opened Available
9 Runspace9 localhost Local Opened InBreakpoint
PS C:\src\universal> get-runspace 9 | Debug-runspace
Debugging Runspace: Runspace9
To end the debugging session type the 'Detach' command at the debugger prompt, or type 'Ctrl+C' otherwise.
Entering debugged runspace on local machine LAPTOP-496LAUK8
[DBG]: [Process:11676]: [Runspace9]: PS C:\src\universal>>
Command or script completed.
To end the debugging session type the 'Detach' command at the debugger prompt, or type 'Ctrl+C' otherwise.
I also cannot end the debugging session. This happens.
I have this error in the logs.
[Info - 13:45:30] Microsoft.PowerShell.EditorServices.Services.PowerShellContextService: PowerShell runtime version: 7.0.2, edition: Core |
[Info - 13:45:30] Microsoft.PowerShell.EditorServices.Handlers.PsesDocumentHighlightHandler: highlight handler loaded |
[Info - 13:45:33] Microsoft.PowerShell.EditorServices.Services.AnalysisService: Unable to find PSSA settings file at 'c:\src\universal\PSScriptAnalyzerSettings.psd1'. Loading default rules. |
[Info - 13:45:33] Microsoft.PowerShell.EditorServices.Services.AnalysisService: PSScriptAnalyzer settings file not found. Falling back to default rules |
[Error - 13:46:07] Microsoft.PowerShell.EditorServices.Services.PowerShellContextService: Exception occurred while executing debugger command:
System.Management.Automation.CommandNotFoundException: The term '__Invoke-ReadLineForEditorServices' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.Invoke[T](IEnumerable input, IList`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.InvokeWithDebugger(IEnumerable`1 input, IList`1 output, PSInvocationSettings settings, Boolean invokeMustRun)
at System.Management.Automation.ScriptDebugger.ProcessCommand(PSCommand command, PSDataCollection`1 output)
at System.Management.Automation.NestedRunspaceDebugger.ProcessCommand(PSCommand command, PSDataCollection`1 output)
at System.Management.Automation.ScriptDebugger.ProcessCommandForActiveDebugger(PSCommand command, PSDataCollection`1 output)
at System.Management.Automation.ScriptDebugger.ProcessCommand(PSCommand command, PSDataCollection`1 output)
at Microsoft.PowerShell.EditorServices.Services.PowerShellContext.PowerShell5Operations.ExecuteCommandInDebugger[TResult](PowerShellContextService powerShellContext, Runspace currentRunspace, PSCommand psCommand, Boolean sendOutputToHost, Nullable`1& debuggerResumeAction) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShellContext\Session\PowerShell5Operations.cs:line 61
at Microsoft.PowerShell.EditorServices.Services.PowerShellContextService.ExecuteCommandInDebugger[TResult](PSCommand psCommand, Boolean sendOutputToHost) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShellContext\PowerShellContextService.cs:line 1955
at Microsoft.PowerShell.EditorServices.Services.PowerShellContextService.ExecuteCommandAsync[TResult](PSCommand psCommand, StringBuilder errorMessages, ExecutionOptions executionOptions) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShellContext\PowerShellContextService.cs:line 713 |
System Details
System Details Output
Issue Description
When creating a background runspace and then attempting to debug it with Debug-Runspace causes the debugger to just continue through and never stop within the background runspace.
Steps to reproduce:
I also cannot end the debugging session. This happens.
I have this error in the logs.
Expected Behaviour
Correctly debug the runspace.
Actual Behaviour
Just drops out of the runspace without breaking.