Skip to content

Refuse time limits that can't work: NaN/Infinity -TimeoutSeconds and negative waits - #63

Merged
HalRiveria-Bot merged 2 commits into
mainfrom
fix/timeout-validation
Nov 17, 2026
Merged

HalRiveria-Bot merged 2 commits into
mainfrom
fix/timeout-validation

Conversation

@HalRiveria-Bot

Copy link
Copy Markdown
Collaborator

Several time-limit parameters took values that can't work, and failed late or not at all:

  • -TimeoutSeconds on Invoke-PkProcessBatch and Invoke-PkProcessDispatch took NaN and +Infinity. Both only checked -lt 0, so these passed and acted as no limit, while a job's own TimeoutSeconds key already refuses both.
  • Negative waits weren't refused. -StreamTimeoutMs -1 (Complete-PkProcess, Invoke-PkProcessWithTimeout) waited until a leftover child let go of the output, forever if it never did, and -2 came back later as a StreamError. Wait-PkProcess -TimeoutMs -1 waited until the program exited, against its "can't overrun" purpose, and -2 threw .NET's raw message. A negative -AbortTimeoutSeconds / -DrainTimeoutSeconds on any engine silently acted as 0.

What changed

Each of these is now refused before anything starts, with a message that names the command and parameter and says what the value means, e.g. Complete-PkProcess: -StreamTimeoutMs must be 0 or more (got -1). It's how long to wait for the output after the program exits, in milliseconds; 0 doesn't wait. 0 keeps its meaning everywhere (no limit, don't wait, or just check). The help for the wait parameters says "0 or more". The batch's and dispatcher's twin checks, and the job-key check in Get-PkJobTimeLimit, now name each other.

Scripts that passed one of these values get an error now instead of the old behavior.

Testing

  • New harness section AU: NaN and +Infinity -TimeoutSeconds on the batch and dispatcher; -5 for -AbortTimeoutSeconds (batch, dispatcher) and -DrainTimeoutSeconds (runspace jobs); -1 for -StreamTimeoutMs (both commands) and Wait-PkProcess -TimeoutMs. All ten failed on the old code (no error) and pass now; a separate check confirms 0 is still accepted for each.
  • Full harness passes in fresh processes on Windows PowerShell 5.1 and PowerShell 7 (521 assertions each).

🤖 Generated with Claude Code

HalRiveria and others added 2 commits November 17, 2026 17:04
…ative waits

-TimeoutSeconds on the batch and dispatcher only checked `-lt 0`, so NaN
and +Infinity passed and acted as no limit, while a job's own
TimeoutSeconds key refuses both. Negative waits weren't refused anywhere:
-StreamTimeoutMs -1 and Wait-PkProcess -TimeoutMs -1 waited without limit,
-2 failed later with .NET's own message, and a negative
-AbortTimeoutSeconds / -DrainTimeoutSeconds acted as 0.

All are now refused before anything starts, with a message naming the
command and parameter. 0 keeps its meaning (no limit, or don't wait). The
batch's and dispatcher's twin checks name each other.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… help

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HalRiveria-Bot
HalRiveria-Bot merged commit 20ca569 into main Nov 17, 2026
2 checks passed
@HalRiveria-Bot
HalRiveria-Bot deleted the fix/timeout-validation branch November 17, 2026 22:16
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.

2 participants