Repository navigation
Record each worker's non-terminating errors with its job - #40
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
A non-terminating error a worker didn't catch (a
Write-Error, a locked file in a cmdlet) was only printed asRunspace 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 successfulEndInvoke.What changed
Invoke-PkRunspaceJobs' result has a newErrorslist, one@{ Job; Error }entry per non-terminating error, shaped like the existingCrashedlist. Errors are still printed as before.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.How it was tested
New harness section AI covers:
Errorswith their job andErrorRecord, and still being printed;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 exceptbatch: a timeout kills the program's children too, which fails intermittently. It fails the same way onmain(4 of 8 tries there), becauseStop-PkProcessTreesometimes reports a program it killed as not killed. That's a separate fix, coming next.🤖 Generated with Claude Code