Skip to content

Record each worker's non-terminating errors with its job - #40

Merged
HalRiveria-Bot merged 2 commits into
mainfrom
feature/runspace-job-errors
Nov 16, 2026
Merged

HalRiveria-Bot merged 2 commits into
mainfrom
feature/runspace-job-errors

Conversation

@HalRiveria-Bot

Copy link
Copy Markdown
Collaborator

What was wrong

A non-terminating error a worker didn't catch (a Write-Error, a locked file in a cmdlet) was only printed as Runspace error: .... Nothing said which job it came from. A worker that wrote such an error and then threw never had that error printed at all, because the error stream was only read after a successful EndInvoke.

What changed

  • Invoke-PkRunspaceJobs' result has a new Errors list, one @{ Job; Error } entry per non-terminating error, shaped like the existing Crashed list. Errors are still printed as before.
  • The main loop and the abort drain now share one private helper, Add-PkJobErrors. It also runs for a worker that crashed, so that worker's earlier errors are printed and recorded before the crash is reported. A crashed worker's error stream holds only the errors from before the throw, never the throw itself (checked on 5.1 and 7), so nothing is counted twice.
  • Help and README: the result's fields, and the "what counts as a crash" bullet. The README also notes that every entry is kept until the call returns.

How it was tested

New harness section AI covers:

  • a worker's errors landing in Errors with their job and ErrorRecord, and still being printed;
  • a crashed worker's earlier error being printed and recorded;
  • an empty run returning an empty list.

The existing drain test now also checks Errors, and the result-shape checks expect the new field. All of these failed before the change. The harness passes on PowerShell 7 (436 assertions). On 5.1, everything passes except batch: a timeout kills the program's children too, which fails intermittently. It fails the same way on main (4 of 8 tries there), because Stop-PkProcessTree sometimes reports a program it killed as not killed. That's a separate fix, coming next.

🤖 Generated with Claude Code

HalRiveria and others added 2 commits November 16, 2026 14:07
An error a worker didn't catch was only printed as "Runspace error: ...", with no way to tell which job it came from, and a worker that wrote an error and then threw never had that error printed at all.

Invoke-PkRunspaceJobs' result gains an Errors list, one @{ Job; Error } entry per non-terminating error, like Crashed. Errors are still printed. Both the main loop and the abort drain go through one new helper, which also runs for a worker that crashed, so its earlier errors are printed and recorded before the crash is reported.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HalRiveria-Bot
HalRiveria-Bot merged commit 7fbad9b into main Nov 16, 2026
2 checks passed
@HalRiveria-Bot
HalRiveria-Bot deleted the feature/runspace-job-errors branch November 16, 2026 19:11
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