Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch problems from Foreach-Object -Parallel #6127

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

arberg
Copy link

@arberg arberg commented Sep 1, 2024

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

cd c:\Users\Administrator\scoop\buckets
dir  | %{push-location $_ ; git reset --hard HEAD~10; Pop-Location}

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:

  • I have read the Contributing Guide.
  • [x ] I have ensured that I am targeting the develop branch.
  • [x ] I have updated the documentation accordingly.
  • [x ] I have updated the tests accordingly.
  • [x ] I have added an entry in the CHANGELOG.

I don't know where to add that entry in changelog, though this would seem sensible:

  • scoop-update: Fix 'scoop update' when powershell fails in Foreach-Object -Parallel' (#6126)

…fe variant. Errors will likely be output should the problem occur, but at least it will work.
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.

1 participant