← All Scenarios · Scenario 08

Nested PowerShell Timeout

08
Nested PowerShell Timeout
PASS
Goal
Verify timeout behaves correctly when PowerShell instances are nested — outer instance calls inner instance which hangs. No deadlock between outer stop and inner pipeline.
Trying to break
Timeout on outer invocation should stop nested invocations gracefully. Runspace state should be clean after timeout. A fresh runspace should be usable immediately after.
2 test stepsPress Start to walk through the scenario step by step.
View full script source (nested-timeout.ps1)
$ps = [PowerShell]::Create()
$ps.Runspace = $rs
$ps.AddScript('Start-Sleep -Seconds 60') > $null
$settings = [PSInvocationSettings]::new()
$settings.Timeout = [TimeSpan]::FromSeconds(3)
try {
    $ps.Invoke($null, $settings) > $null
} catch [TimeoutException] {
    Write-Host 'PASS: TimeoutException from nested scenario'
}

Linked Requirements

REQ-02 → REQ-09 → REQ-10 →
← Previous