From 4e110ca49f6eaa24102faac68ebb0471623564b9 Mon Sep 17 00:00:00 2001 From: Hal <22532613+HalRiveria@users.noreply.github.com> Date: Wed, 18 Nov 2026 16:04:46 -0500 Subject: [PATCH 1/2] Wait for a job's output alongside the other jobs, not inside -JobFinalize Complete-PkProcess's wait for the output (up to 15 s) ran inside the batch's -JobFinalize, on the dispatch loop's own thread, so while one program's output was held open no other job was polled, started, killed at its time limit or stopped by an abort. The dispatcher's default -JobPollCompleted, which the batch uses, now counts a job as done once its program has exited and both reads have ended, or 15 s after it saw the exit. The job keeps its slot meanwhile. Complete-PkProcess waits only what's left of that (OutputWait), and after an abort's wait the final pass sets OutputWaitOver, so a job whose program had finished takes the output that arrived instead of being force-stopped. Co-Authored-By: Claude Opus 5.5 --- ParallelKit.Harness.ps1 | 72 +++++++++++++++++++++++++++++++++++++++++ ParallelKit.ps1 | 49 ++++++++++++++++++++++++---- README.md | 6 ++-- 3 files changed, 118 insertions(+), 9 deletions(-) diff --git a/ParallelKit.Harness.ps1 b/ParallelKit.Harness.ps1 index aa1074c..014897e 100644 --- a/ParallelKit.Harness.ps1 +++ b/ParallelKit.Harness.ps1 @@ -4611,6 +4611,78 @@ $r = Complete-PkProcess @{ Proc = $s['Proc']; StdoutTask = $baFailed.Task; Stder Test-Assert (-not $r.StreamTimedOut -and $r.StreamError -eq 'Test: the read failed.' -and $null -eq $r.Stdout) ("a failed read next to one that ended gives the read's own reason (StreamError '" + $r.StreamError + "')") Write-Host "" +Write-Host "=== BB: a job waiting for its output doesn't hold up the others ===" -ForegroundColor Cyan +# Each held command's cmd exits at once and leaves a ping holding its output +# for a few seconds, so its output ends well inside the stream timeout. The +# wait for it used to run inside -JobFinalize, on the dispatch loop's own +# thread: no other job was polled, started, timed or stopped meanwhile. The +# pings carry -w 4321 so this section can find and kill its own. +Reset-Harness +function Stop-HarnessTaggedPings { + foreach ($p in @(Get-CimInstance Win32_Process -Filter "Name='PING.EXE' AND CommandLine LIKE '%-w 4321 %'")) { Stop-Process -Id $p.ProcessId -Force -ErrorAction SilentlyContinue } +} +function New-HarnessHeldCommand([int]$Seconds, $Key) { + return @{ FilePath = $cmdExe; Arguments = ('/d /c echo held& start /b ping -n ' + ($Seconds + 1) + ' -w 4321 127.0.0.1 >nul'); Key = $Key } +} +try { + # Two slots: one job waits about 6 s for its output while four 1 s + # programs go through the other slot, finishing by about 4 s. + $bbAt = [System.Collections.Generic.List[double]]::new() + $sw = [System.Diagnostics.Stopwatch]::StartNew() + $bbCommands = @(New-HarnessHeldCommand -Seconds 6 -Key 'held') + @(1..4 | ForEach-Object { @{ FilePath = $cmdExe; Arguments = '/d /c ping -n 2 127.0.0.1 >nul'; Key = 'quick' } }) + $b = Invoke-PkProcessBatch -MaxConcurrent 2 -Commands $bbCommands -OnComplete { param($c, $r) if ($c['Key'] -eq 'quick') { $bbAt.Add($sw.Elapsed.TotalSeconds) } }.GetNewClosure() + $sw.Stop() + $bbLast = $null; if ($bbAt.Count -gt 0) { $bbLast = [math]::Round(($bbAt | Measure-Object -Maximum).Maximum, 1) } + $bbHeld = @($b.Results | Where-Object { $_.Command['Key'] -eq 'held' -and $_.Stdout -match 'held' -and -not $_.StreamTimedOut }) + Test-Assert ($bbAt.Count -eq 4 -and $bbLast -lt 5.5 -and $bbHeld.Count -eq 1) ("batch: other programs keep running through the free slot while one waits for its output (last of 4 done at " + $bbLast + " s; the held one whole: " + ($bbHeld.Count -eq 1) + ")") + + # One job waits for its output while the other passes its time limit: + # the limit is still enforced on time. + $b = Invoke-PkProcessBatch -MaxConcurrent 2 -Commands @((New-HarnessHeldCommand -Seconds 6 -Key 'held'), @{ FilePath = $pingExe; Arguments = '-n 30 127.0.0.1'; TimeoutSeconds = 2; Key = 'limited' }) + $bbLimited = @($b.Results | Where-Object { $_.Command['Key'] -eq 'limited' }) + $bbKilledAt = $null; if ($bbLimited.Count -eq 1 -and $null -ne $bbLimited[0].Duration) { $bbKilledAt = [math]::Round($bbLimited[0].Duration.TotalSeconds, 1) } + Test-Assert ($bbLimited.Count -eq 1 -and $bbLimited[0].TimedOut -and $null -ne $bbKilledAt -and $bbKilledAt -lt 3.5) ("batch: a program's 2 s time limit is enforced while another waits for its output (killed at " + $bbKilledAt + " s)") + + # An abort while a job waits for its output: acted on at once, and after + # the abort's wait the job keeps what arrived rather than counting as + # force-stopped (its program had finished). + Reset-PkAbortState + $sw = [System.Diagnostics.Stopwatch]::StartNew() + $b = Invoke-PkProcessBatch -MaxConcurrent 2 -AbortTimeoutSeconds 1 -OnComplete { param($c, $r) if ($c['Key'] -eq 'quick') { Request-PkAbort } } -Commands @((New-HarnessHeldCommand -Seconds 8 -Key 'held'), @{ FilePath = $cmdExe; Arguments = '/d /c ping -n 2 127.0.0.1 >nul'; Key = 'quick' }) + $sw.Stop() + Reset-PkAbortState + $bbHeld = @($b.Results | Where-Object { $_.Command['Key'] -eq 'held' }) + $bbHeldText = 'no result' + if ($bbHeld.Count -eq 1) { $bbHeldText = "Aborted " + $bbHeld[0].Aborted + ", StreamTimedOut " + $bbHeld[0].StreamTimedOut + ", Stdout '" + ([string]$bbHeld[0].Stdout).Trim() + "'" } + Test-Assert ($b.Aborted -and $sw.Elapsed.TotalSeconds -lt 5 -and $bbHeld.Count -eq 1 -and -not $bbHeld[0].Aborted -and $bbHeld[0].StreamTimedOut -and $bbHeld[0].Stdout -match 'held' -and $b.ForceKilledCount -eq 0) ("batch: an abort while a job waits for its output ends the run in time, and that job keeps what arrived (" + [math]::Round($sw.Elapsed.TotalSeconds, 1) + " s, " + $bbHeldText + ", force-stopped " + $b.ForceKilledCount + ")") + + # Output held past the 15 s stream timeout: the poll gives up at 15 s, and + # Complete-PkProcess doesn't wait another 15 on top. + $sw = [System.Diagnostics.Stopwatch]::StartNew() + $b = Invoke-PkProcessBatch -Commands @(New-HarnessHeldCommand -Seconds 25 -Key 'long') + $sw.Stop() + $bbLong = @($b.Results) + Test-Assert ($bbLong.Count -eq 1 -and $bbLong[0].StreamTimedOut -and $bbLong[0].Stdout -match 'held' -and $sw.Elapsed.TotalSeconds -ge 14 -and $sw.Elapsed.TotalSeconds -lt 20) ("batch: output held past the stream timeout is given up on once, after 15 s (" + [math]::Round($sw.Elapsed.TotalSeconds, 1) + " s)") + Stop-HarnessTaggedPings + + # The dispatcher's default poll, with Complete-PkProcess in -JobFinalize: + # the same time-limit case. + $bbFeed = @{ Given = $false } + $bbJobs = @((New-HarnessHeldCommand -Seconds 6 -Key 'held'), @{ FilePath = $pingExe; Arguments = '-n 30 127.0.0.1'; TimeoutSeconds = 2; Key = 'limited' }) + $bbDone = @{} + $null = Invoke-PkProcessDispatch -MaxConcurrent 2 ` + -GroupProvider { if ($bbFeed.Given) { return $null }; $bbFeed.Given = $true; return @{ Name = 'held' } }.GetNewClosure() ` + -JobBuilder { param($g) return $bbJobs }.GetNewClosure() ` + -JobFinalize { param($j, $q) $bbDone[$j['Key']] = @{ Result = (Complete-PkProcess -Job $j); TimedOut = $j['TimedOut'] } }.GetNewClosure() + $bbKilledAt = $null; if ($bbDone.ContainsKey('limited') -and $null -ne $bbDone['limited'].Result.Duration) { $bbKilledAt = [math]::Round($bbDone['limited'].Result.Duration.TotalSeconds, 1) } + $bbWhole = ($bbDone.ContainsKey('held') -and $bbDone['held'].Result.Stdout -match 'held' -and -not $bbDone['held'].Result.StreamTimedOut) + Test-Assert ($bbDone.Count -eq 2 -and $bbDone['limited'].TimedOut -and $null -ne $bbKilledAt -and $bbKilledAt -lt 3.5 -and $bbWhole) ("dispatcher: with the default poll, a 2 s time limit is enforced while another job waits for its output (killed at " + $bbKilledAt + " s; the held one whole: " + $bbWhole + ")") +} finally { + Stop-HarnessTaggedPings + Reset-PkAbortState +} +Write-Host "" + Set-PkMessageHandler -Handler $null Reset-PkAbortState diff --git a/ParallelKit.ps1 b/ParallelKit.ps1 index fb5ca71..a68d8d5 100644 --- a/ParallelKit.ps1 +++ b/ParallelKit.ps1 @@ -1791,7 +1791,9 @@ function Complete-PkProcess { # What Start-PkProcess returned, or a dispatcher job with the same keys. # .PARAMETER StreamTimeoutMs # How long to wait for the output after the program exits, - # in milliseconds (default 15000); 0 or more, and 0 doesn't wait. + # in milliseconds (default 15000); 0 or more, and 0 doesn't wait. On a job + # the dispatcher's default -JobPollCompleted has already waited on, only + # what's left of it, so with the default nothing. # .PARAMETER Dispose # Dispose the process object afterwards. # .OUTPUTS @@ -1804,6 +1806,7 @@ function Complete-PkProcess { param( [Parameter(Mandatory, Position = 0)] [hashtable]$Job, + # The dispatcher's default -JobPollCompleted waits the same 15 s: keep the two in step. [int]$StreamTimeoutMs = 15000, [switch]$Dispose ) @@ -1820,9 +1823,15 @@ function Complete-PkProcess { $tasks = [System.Collections.Generic.List[System.Threading.Tasks.Task]]::new() if ($null -ne $Job['StdoutTask']) { $tasks.Add($Job['StdoutTask']) } if ($null -ne $Job['StderrTask']) { $tasks.Add($Job['StderrTask']) } + # The dispatcher's default poll waits for the output alongside the other + # jobs, timing it with OutputWait, and the final pass after an abort's + # wait sets OutputWaitOver: what's left of the wait, and none at all then. + $waitMs = $StreamTimeoutMs + if ($Job['OutputWaitOver']) { $waitMs = 0 } + elseif ($Job['OutputWait'] -is [System.Diagnostics.Stopwatch]) { $waitMs = [int][Math]::Max(0, $StreamTimeoutMs - $Job['OutputWait'].ElapsedMilliseconds) } if ($tasks.Count -gt 0) { try { - if (-not [System.Threading.Tasks.Task]::WaitAll($tasks.ToArray(), $StreamTimeoutMs)) { $result.StreamTimedOut = $true } + if (-not [System.Threading.Tasks.Task]::WaitAll($tasks.ToArray(), $waitMs)) { $result.StreamTimedOut = $true } } catch { $result.StreamError = [string]$_.Exception.Message } @@ -1944,7 +1953,8 @@ function Invoke-PkProcessDispatch { # # The dispatcher keeps its own state on each job hashtable. Don't use these keys # for anything else: GroupKey, SlotReleased, Proc, StdoutTask, StderrTask, - # Stopwatch, TimeLimit, TimedOut, StartFailureReported. It also sets Group to + # Stopwatch, TimeLimit, TimedOut, StartFailureReported, OutputWait, + # OutputWaitOver. It also sets Group to # the job's group, unless the job already has a Group of its own. The default # starter reads FilePath, Arguments (a string as written, or a list quoted one # argument per element), WorkingDirectory and OutputEncoding from the job. A @@ -1960,8 +1970,11 @@ function Invoke-PkProcessDispatch { # { param($job) } that starts the job and returns it with .Proc set. Default: # Start-PkProcess on the job's FilePath and Arguments. # .PARAMETER JobPollCompleted - # { param($job) } returning $true once the job is finished. Default: - # $job['Proc'].HasExited. Only its last output value counts. + # { param($job) } returning $true once the job is finished. Only its last + # output value counts. Default: once the program has exited and its output + # has been read, or 15 s after the exit if a program it started holds the + # output open (the job keeps its slot meanwhile), so Complete-PkProcess in + # -JobFinalize doesn't wait and the other jobs carry on. # .PARAMETER JobFinalize # { param($job, $pendingQueue) } called once per finished job; collect its # result with Complete-PkProcess. Enqueue new job hashtables onto $pendingQueue @@ -2083,7 +2096,25 @@ function Invoke-PkProcessDispatch { } # The default poll reads $pkJob['Proc'], so a started job must have one. $pkRequireProc = ($null -eq $pkJobPollCompleted) - if ($null -eq $pkJobPollCompleted) { $pkJobPollCompleted = { param($pkJob) return $pkJob['Proc'].HasExited } } + if ($null -eq $pkJobPollCompleted) { + # Done once the program has exited and its output has been read, so + # Complete-PkProcess in -JobFinalize has nothing to wait for: waiting + # there would stall the whole loop. A job whose output a leftover + # program holds open keeps its slot until the reads end or 15 s pass + # (Complete-PkProcess's default -StreamTimeoutMs; keep the two in + # step), timed by OutputWait, which Complete-PkProcess reads. After an + # abort's wait the final pass sets OutputWaitOver: it takes what has + # arrived. + $pkJobPollCompleted = { + param($pkJob) + if (-not $pkJob['Proc'].HasExited) { return $false } + $pkOut = $pkJob['StdoutTask']; $pkErr = $pkJob['StderrTask'] + if (($pkOut -isnot [System.Threading.Tasks.Task] -or $pkOut.IsCompleted) -and ($pkErr -isnot [System.Threading.Tasks.Task] -or $pkErr.IsCompleted)) { return $true } + if ($pkJob['OutputWaitOver']) { return $true } + if ($pkJob['OutputWait'] -isnot [System.Diagnostics.Stopwatch]) { $pkJob['OutputWait'] = [System.Diagnostics.Stopwatch]::StartNew() } + return ($pkJob['OutputWait'].ElapsedMilliseconds -ge 15000) + } + } if ($null -eq $pkJobAbortCleanup) { $pkJobAbortCleanup = { param($pkJob) } } if ($null -eq $pkGroupCompleteCallback) { $pkGroupCompleteCallback = { param($pkGroup) } } @@ -2301,6 +2332,7 @@ function Invoke-PkProcessDispatchCore { # its old, disposed process: cleared first. if ($pkJob['SlotReleased']) { $pkJob['Proc'] = $null; $pkJob['StdoutTask'] = $null; $pkJob['StderrTask'] = $null; $pkJob['Stopwatch'] = $null + $pkJob['OutputWait'] = $null; $pkJob['OutputWaitOver'] = $null } $pkJob['SlotReleased'] = $false $pkStarting = $pkJob @@ -2486,6 +2518,11 @@ function Invoke-PkProcessDispatchCore { # force-stopped. Keep in sync with the two blocks above, minus the time # limit (whatever is left is force-stopped just below). if ($pkRunning.Count -gt 0) { + # The wait is over: a job whose program has finished, and that is + # only waiting for its output, takes what has arrived (the default + # poll and Complete-PkProcess read this) rather than being + # force-stopped. + foreach ($pkJob in $pkRunning) { $pkJob['OutputWaitOver'] = $true } $pkStillWaiting = [System.Collections.Generic.List[hashtable]]::new() foreach ($pkJob in $pkRunning) { $pkCbDone = $false diff --git a/README.md b/README.md index 0e26743..f019c36 100644 --- a/README.md +++ b/README.md @@ -144,7 +144,7 @@ Programs run in your current location (`Get-Location`) unless a command says oth - `Aborted` is `$true` for a command an abort killed or kept from starting. - `TimedOut` is `$true` for a program `-TimeoutSeconds` killed. - `Duration` is how long the program ran, from its start to its exit or kill, as a `[TimeSpan]`: not the time it waited for a slot, nor any wait for its output afterwards. It's `$null` for a command that never started. Sorting on it finds the slow ones: `$batch.Results | Sort-Object Duration -Descending | Select-Object -First 10`. -- `StreamTimedOut` means the output read gave up 15 seconds after the program exited, on stdout, stderr or both, which only happens when a program it started is still holding the output open. Each stream comes back with what arrived before then: one held open is cut short, the other is whole. The read of a held stream carries on in the background until that program lets go of it; it's in the kit's Job Object, so that's when PowerShell exits at the latest. Until then that read keeps a thread of its own, one per held stream, so other programs' output isn't held up behind it, and drops what it reads, so a program that keeps writing doesn't fill memory with output nobody can get. What came back is that stream's text from then on, so calling `Complete-PkProcess` again on the same job returns the same text, and so does the read task's `Result` once the stream ends. `StreamError` means a read failed, and that stream comes back `$null`; it can be set alongside `StreamTimedOut` when the other stream was held open. +- `StreamTimedOut` means the output read gave up 15 seconds after the program exited, on stdout, stderr or both, which only happens when a program it started is still holding the output open. Each stream comes back with what arrived before then: one held open is cut short, the other is whole. The read of a held stream carries on in the background until that program lets go of it; it's in the kit's Job Object, so that's when PowerShell exits at the latest. Until then that read keeps a thread of its own, one per held stream, so other programs' output isn't held up behind it, and drops what it reads, so a program that keeps writing doesn't fill memory with output nobody can get. What came back is that stream's text from then on, so calling `Complete-PkProcess` again on the same job returns the same text, and so does the read task's `Result` once the stream ends. `StreamError` means a read failed, and that stream comes back `$null`; it can be set alongside `StreamTimedOut` when the other stream was held open. While a program's output is held open, its command keeps its slot, but the other commands carry on: they keep starting, finishing and being killed at their time limits, and an abort is acted on at once. If an abort's wait for running programs ends while one is still waiting for its output, it gets what has arrived, with `StreamTimedOut`, rather than counting as force-stopped. `Results` is in the order commands finished, not the order you gave them. Use `Command` to match them up, or give each command your own key (`Index = $n`) and sort on it: `$batch.Results | Sort-Object { $_.Command.Index }`. @@ -249,11 +249,11 @@ $dispatch = Invoke-PkProcessDispatch @dispatchParams All of these callbacks run on whichever thread called the dispatcher: the main thread normally, or the worker if you call it from inside a runspace job (in which case the worker rules apply to them). - **`-GroupCompleteCallback` also runs for a group an abort cut short**, so you can record the jobs in it that did finish. Before doing anything irreversible there (zipping the folder, deleting sources), check `Test-PkCancelRequested` (or your own `-CancelToken`) and skip it if true. -- `-JobFinalize` is called once per finished job. Collect its exit code and output there with `Complete-PkProcess -Job $job`; the dispatcher disposes the process right after. +- `-JobFinalize` is called once per finished job. Collect its exit code and output there with `Complete-PkProcess -Job $job`; the dispatcher disposes the process right after. With the default `-JobPollCompleted`, a job is finished once its program has exited and its output has been read, or 15 seconds after the exit when a program it started holds the output open (the job keeps its slot meanwhile, and the other jobs carry on), so `Complete-PkProcess` there has nothing left to wait for. A longer `-StreamTimeoutMs` there waits only the rest, but on the dispatch loop's own thread, holding up the other jobs; a shorter one can't shorten the poll's 15 seconds. With your own `-JobPollCompleted`, `Complete-PkProcess` waits as it does anywhere else. - Groups are pulled lazily, at most `-MaxQueueAhead` (default 3) ahead. - A group can be any value: a hashtable, a path, a name. Each job gets its group as `$job.Group`. - Each `-GroupProvider` call outputs exactly one group, or `$null` to end, and nothing else: `return $group`, `return ,@('a', 'b', 'c')` for a list as one group (the comma keeps a one-item list a list), or `return $null`. Anything else it lets out (an `ArrayList.Add` index, say) becomes part of the group, so discard it with `$null = ...`. Output that ends in `$null` is taken as the end, with a warning, so a list group can't end in `$null`. -- The dispatcher keeps its state on the job hashtables. Don't use these names for your own job fields: `GroupKey`, `SlotReleased`, `Proc`, `StdoutTask`, `StderrTask`, `Stopwatch`, `TimeLimit`, `TimedOut`, `StartFailureReported`. (`Group` is yours if you set it yourself.) +- The dispatcher keeps its state on the job hashtables. Don't use these names for your own job fields: `GroupKey`, `SlotReleased`, `Proc`, `StdoutTask`, `StderrTask`, `Stopwatch`, `TimeLimit`, `TimedOut`, `StartFailureReported`, `OutputWait`, `OutputWaitOver`. (`Group` is yours if you set it yourself.) - `-TimeoutSeconds 600` kills a job's program, and anything it started, if it's still running after 10 minutes. The default, 0, means no limit, and it can be fractional. A job's own `TimeoutSeconds` key overrides it; 0 opts the job out, and a bad value is a failed start. The killed job still goes through `-JobFinalize`, where `$job['TimedOut']` is `$true`, and other jobs carry on. The limit stays in force while an abort waits for running jobs. A retry gets a fresh clock. A job whose `.Proc` isn't a process isn't timed: `-JobPollCompleted` is the place for its limit. - To retry a job or add follow-up work, enqueue job hashtables onto `$pending` inside `-JobFinalize`. They join the same group, and the group isn't complete until they've all finished. A retry can start within milliseconds of the failure, so cap the number of retries, and don't count on the gap for something like a locked file to clear. - Supply `-JobStarter { param($job) ... }` to start jobs yourself. It must set `$job.Proc` and should return the job. A starter that is just `Start-PkProcess ...` works too: its result is folded into your job. Throw to report a job that couldn't start. From d868d0ea4ed56602c5168db2a2ecd07167c2e6f1 Mon Sep 17 00:00:00 2001 From: Hal <22532613+HalRiveria@users.noreply.github.com> Date: Wed, 18 Nov 2026 16:06:21 -0500 Subject: [PATCH 2/2] Give the final pass a short wait for output that is about to end After an abort's wait, a program that exited just before the final pass could still have its last output in flight. Complete-PkProcess now waits up to 250 ms then, instead of not at all. Co-Authored-By: Claude Opus 5.5 --- ParallelKit.ps1 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ParallelKit.ps1 b/ParallelKit.ps1 index a68d8d5..bd3fc15 100644 --- a/ParallelKit.ps1 +++ b/ParallelKit.ps1 @@ -1824,11 +1824,13 @@ function Complete-PkProcess { if ($null -ne $Job['StdoutTask']) { $tasks.Add($Job['StdoutTask']) } if ($null -ne $Job['StderrTask']) { $tasks.Add($Job['StderrTask']) } # The dispatcher's default poll waits for the output alongside the other - # jobs, timing it with OutputWait, and the final pass after an abort's - # wait sets OutputWaitOver: what's left of the wait, and none at all then. + # jobs, timing it with OutputWait: only what's left of the wait here. The + # final pass after an abort's wait sets OutputWaitOver: at most 250 ms + # then, enough for a program that exited just before to have its output + # read to the end, short enough for a window close. $waitMs = $StreamTimeoutMs - if ($Job['OutputWaitOver']) { $waitMs = 0 } - elseif ($Job['OutputWait'] -is [System.Diagnostics.Stopwatch]) { $waitMs = [int][Math]::Max(0, $StreamTimeoutMs - $Job['OutputWait'].ElapsedMilliseconds) } + if ($Job['OutputWait'] -is [System.Diagnostics.Stopwatch]) { $waitMs = [int][Math]::Max(0, $StreamTimeoutMs - $Job['OutputWait'].ElapsedMilliseconds) } + if ($Job['OutputWaitOver']) { $waitMs = [Math]::Min($waitMs, 250) } if ($tasks.Count -gt 0) { try { if (-not [System.Threading.Tasks.Task]::WaitAll($tasks.ToArray(), $waitMs)) { $result.StreamTimedOut = $true }