Skip to content

Debug PSTask PSInvalidOperationException #3363

Open
@AlbertWaelti

Description

@AlbertWaelti

Issue Type: Bug

When debugging a PSTaskJob (Runspace) a get the following exception:
.PSInvalidOperationException: The pipeline was not run because a pipeline is already running. Pipelines cannot be run concurrently.

TestScript.ps1

$files = @("file1.txt","file2.txt","file3.txt");

$files | ForEach-Object -AsJob -Parallel {

    Wait-Debugger
    Write-Output "Scanning $($_)";
}

=====================================
Command to reproduce in Powershell Integrated Terminal:

PS> .\TestScript.ps1
PS> Get-Runspace
 Id Name            ComputerName    Type          State         Availability
 -- ----            ------------    ----          -----         ------------
  1 Runspace1       localhost       Local         Opened        Available   
  4 Runspace4       localhost       Local         Opened        Busy        
  6 PSTask:1        localhost       Local         Opened        InBreakpoint
  7 PSTask:2        localhost       Local         Opened        InBreakpoint
  8 PSTask:3        localhost       Local         Opened        InBreakpoint
PS> Get-Runspace -Id 6 | Debug-Runspace

Debugging Runspace: PSTask:1
To end the debugging session type the 'Detach' command at the debugger prompt, or type 'Ctrl+C' otherwise.


Entering debugged runspace on local machine NB0001
[DBG]: [Process:17600]: [PSTask:1]: PS C:\Users\Albert\Source\Repos\Test>> l


    1:
    2:
    3:*     Wait-Debugger
    4:      Write-Output "Scanning $($_)";
    5:


[DBG]: [Process:17600]: [PSTask:1]: PS C:\Users\Albert\Source\Repos\Test>> v

PSInvalidOperationException: The pipeline was not run because a pipeline is already running. Pipelines cannot be run concurrently.

The Debugger crashes and returns the same exception in a loop

Extension version: 2021.2.2
VS Code version: Code 1.56.2 (054a9295330880ed74ceaedda236253b4f39a335, 2021-05-12T17:13:13.157Z)
OS version: Windows_NT x64 10.0.19041

System Info
Item Value
CPUs Intel(R) Core(TM) i7-3840QM CPU @ 2.80GHz (8 x 2794)
GPU Status 2d_canvas: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: enabled_on
video_decode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 15.91GB (5.58GB free)
Process Argv --crash-reporter-id e3696b06-ea94-400b-b7e5-70c7ac80803d
Screen Reader no
VM 0%

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions