Retry Test-Module manifest calls to avoid sporadic failures due to concurrency/thread safety issue in PowerShell itself #1257
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.
PR Summary
Fixes #901
Fixes #902
Retry
Test-ModuleManifest
that can sometimes throw due to a thread safety issue in PowerShell itself (I can repro in versions 5-7 and maybe later I want to look into fixing it in PS itself).This makes PSSA more stable by retrying the operation and resolves the issue as I manually tested. I am keeping the existing method that it calls public to not break the public API although I don't think anyone is using it.
I tried to write a test for it but although I can reproduce locally, it is hard to write test that reproduces this race condition.
I also opened a PR in PowerShell itself to get it fixed in v7: PowerShell/PowerShell#9860
UPDATE: I opened PR #1258 which might be a better alternative by locking the calls of
Test-ModuleManifest
PR Checklist
.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
to the beginning of the title and remove the prefix when the PR is ready.