Skip to content

Make Run.ParallelThrottleLimit = 1 run sequentially in the current session - #2973

Closed
nohwnd wants to merge 1 commit into
mainfrom
nohwnd-parallel-ux
Closed

Make Run.ParallelThrottleLimit = 1 run sequentially in the current session#2973
nohwnd wants to merge 1 commit into
mainfrom
nohwnd-parallel-ux

Conversation

@nohwnd

@nohwnd nohwnd commented Aug 12, 2026

Copy link
Copy Markdown
Member

Comes out of #2971, where @DarkLite1 described the pattern he uses in his own code: one function that runs a scriptblock over items, and when you set -ThrottleLimit 1 it drops to a plain foreach on the main thread so you can step through it. Same knob for concurrency and for debugging.

Run.ParallelThrottleLimit = 1 did not do that. It ran one file at a time, but still inside a worker runspace, so you got no speedup and no debugging: breakpoints are per runspace, a breakpoint set in the session that calls Invoke-Pester never hits inside a worker.

Now 1 falls back to the normal sequential path, next to the fallbacks we already have (Windows PowerShell 5.1, ScriptBlock containers, Run.SkipRemainingOnFailure = 'Run'). The banner also stops saying "in parallel", because the run is not parallel.

No new configuration option, and no new switch on Invoke-Pester. Turn the throttle you already have down to 1 and you can debug the file.

Before:

Invoke-Pester -Configuration @{ Run = @{ Parallel = $true; ParallelThrottleLimit = 1 } }
# file 1 ran in runspace 2, breakpoint hits: 0

After:

Invoke-Pester -Configuration @{ Run = @{ Parallel = $true; ParallelThrottleLimit = 1 } }
# file 1 ran in runspace 1, breakpoint hits: 1

Tests added in tst/Pester.RSpec.Parallel.ts.ps1: the breakpoint hits, the banner does not claim parallel, and the counts match a parallel run. test.ps1 -File tst/Pester.RSpec.Parallel.ts.ps1 passes 25/25, PesterConfiguration.Tests.ps1 and Help.Tests.ps1 pass, and Invoke-ScriptAnalyzer on src/Main.ps1 reports the same 9 pre-existing findings as main.

Open question: someone might want 1 file at a time but still isolated in a runspace, to tell an isolation problem apart from a concurrency problem. That is what this takes away. I think the debugging case is worth more, LMK if you disagree.

🤖

…ssion

Throttling to 1 already meant one file at a time, but the file still ran in
a worker runspace. That is the worst of both: no speedup, and no debugging,
because breakpoints are set per runspace so a breakpoint set in the session
that called Invoke-Pester never hits inside a worker.

Now 1 falls back to the normal sequential path, next to the other fallbacks
(Windows PowerShell 5.1, ScriptBlock containers, SkipRemainingOnFailure =
'Run'). So the same configuration can be used to step through a test that
only misbehaves under Run.Parallel, by turning the throttle down to 1,
instead of remembering a second option to flip.

🤖
@nohwnd

nohwnd commented Aug 12, 2026

Copy link
Copy Markdown
Member Author

Not the direction we want to take. Enabling Run.Parallel means the files run in runspaces, throttling to 1 just means one runspace at a time. If you don't want parallel, don't enable it.

🤖

@nohwnd nohwnd closed this Aug 12, 2026
@nohwnd
nohwnd deleted the nohwnd-parallel-ux branch August 12, 2026 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant