Catch problems from Foreach-Object -Parallel #6127
Open
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.
Catch problems from Foreach-Object -Parallel and fall back to using the non-parallel safe variant.
Errors will likely be output should the problem occur, but at least it will work.
See details of the problem here:
#6126
It's not pretty but it should work according to my tests.
See
Description
I just copied the non-parallel script-block into a function. If the parallel fails, I revert to the non-parallel. I know the catch should work and actually catch something, as I have seen that in my logs when I wrapped the 'scoop update' in a try-catch.
Motivation and Context
Actually I'm unsure if this is a powershell issue or whether its scoop using it wrongly.
Closes #6126
How Has This Been Tested?
I unfortunately could not trigger the problem. So I have only tested it by checking it works, and by
and reverting my buckets running this in the buckets dir to give it something to work on
I've checked it works in powershell5 and powershell 7.4.5. I have (temporarily) added a
throw "test"
above the foreach -parallel, to check the fallback code in pwsh 7. This is to simulate the behaviour of pwsh I have detected in my testing from when problem occurs.Checklist:
develop
branch.I don't know where to add that entry in changelog, though this would seem sensible: