PowerShell / PowerShell/vscode-powershell
Debug PSTask PSInvalidOperationException
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.9k
- Forks
- 547
- PR merge metrics
- No merged PRs in 30d
Description
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% |
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied TestScript.ps1 reproduction, then run Get-Runspace and Debug-Runspace against the PSTask runspaces. Trace the debugger behavior when a runspace is InBreakpoint and the pipeline is already running. Done means debugging no longer crashes or repeats the PSInvalidOperationException loop.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell, typescript, vscode
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100