Repository navigation
Worker-safety check: fixes from review of the default-on change - #10
Merged
Merged
Conversation
- The job-value scan no longer throws on a collection running workers
are changing (a shared results sink with -NextJobProvider); it skips
it instead of failing the run.
- Typed collections that can't hold a scriptblock (byte[], string[],
List[int]) aren't walked, so big data job values don't cost a
PowerShell loop per job.
- The scan looks three levels deep and into [pscustomobject]
properties, so @(@{ Run = {...} }) is caught.
- Command lookups read the Alias: and Function: drives instead of
Get-Command, which searched every installed module for unknown names
on every call.
- A function from a module imported by path (not loadable by name in a
worker) is flagged again, with a message saying how to fix it.
- Storing a scriptblock in a collection (.Add, .Enqueue, ...) is no
longer flagged as a delegate.
- Harness: alias-to-unshared-function coverage is back.
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.
Follow-ups to #5, from a review after it merged.
What was wrong, and what changed:
-NextJobProvider, the scriptblock scan runs while earlier workers are going. A results sink shared by every job (a synchronizedArrayListor hashtable) threw "Collection was modified" and stopped the run. Such a value is now skipped instead.byte[]of file contents or a largestring[]cost a PowerShell loop over every element before each worker started. Collections whose element type can't hold a scriptblock aren't walked now.@(@{ Run = { ... } })passed. It now looks three levels deep and into[pscustomobject]properties.Get-Commandcost on every call. The check ranGet-Commandfor each command name, and an unknown name searched every installed module. That happened on everyInvoke-PkRunspaceJobscall, now that the check is on by default. It now reads theAlias:andFunction:drives.$env:PSModulePathor share the function.$list.Add($sb),$map.Add($k, $sb)and$queue.Enqueue($sb)were flagged as delegates. Collection-storage methods are now exempt. The README notes the one case this misses (a collection typed to hold delegates).Testing. 188 assertions pass on Windows PowerShell 5.1, and on PowerShell 7.6 when merged with #6. Six of the new assertions fail against
main's kit:[pscustomobject]property;byte[]taking 1.5s against under 1s;The
Get-Commandchange has no timing assertion, since a threshold would be flaky on CI.🤖 Generated with Claude Code