Skip to content

Conversation

@vszakats
Copy link

@vszakats vszakats commented Mar 26, 2025

To avoid transient network or server issues.


I'm not sure if the required PowerShell is present in CI runners. 5.1 doesn't support this option, 7.4 (LTS) does.
A CI run should clarify it.

Ref: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-7.4#-maximumretrycount

To avoid transient network or server issues.

Fixes #9
gstrauss added a commit to gstrauss/lighttpd1.4 that referenced this pull request Mar 26, 2025
@gstrauss
Copy link
Contributor

Tested here and failed: https://github.com/gstrauss/lighttpd1.4/actions/runs/14082875060/job/39439677948

Invoke-WebRequest : A parameter cannot be found that matches parameter name 'MaximumRetryCount'.
At D:\a\_temp\d1334e20-2170-4e8a-a056-1a82d41828a2.ps1:3 char:77
+ ... ygwin.com/setup-x86_64.exe -OutFile C:\setup.exe -MaximumRetryCount 3
+                                                      ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Invoke-WebRequest], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

The workflow is configured runs-on: windows-latest
and the full command run in the output above is
Invoke-WebRequest https://cygwin.com/setup-x86_64.exe -OutFile C:\setup.exe -MaximumRetryCount 3

Would you file an issue (elsewhere) to request upgrading PS in the github Windows CI runners?

@vszakats
Copy link
Author

Tested here and failed: https://github.com/gstrauss/lighttpd1.4/actions/runs/14082875060/job/39439677948

Invoke-WebRequest : A parameter cannot be found that matches parameter name 'MaximumRetryCount'.
At D:\a\_temp\d1334e20-2170-4e8a-a056-1a82d41828a2.ps1:3 char:77
+ ... ygwin.com/setup-x86_64.exe -OutFile C:\setup.exe -MaximumRetryCount 3
+                                                      ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Invoke-WebRequest], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

The workflow is configured runs-on: windows-latest and the full command run in the output above is Invoke-WebRequest https://cygwin.com/setup-x86_64.exe -OutFile C:\setup.exe -MaximumRetryCount 3

Would you file an issue (elsewhere) to request upgrading PS in the github Windows CI runners?

@gstrauss Thanks a lot for testing!

I'd prefer not to file it there, it's too far down the rabbit hole.

That said an upgrade would be nice indeed, not just for this.

@gstrauss
Copy link
Contributor

Ref: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-7.4#-maximumretrycount

-MaximumRetryCount

Specifies how many times PowerShell retries a connection when a failure code between 400 and 599, inclusive or 304 is received. Also see RetryIntervalSec parameter for specifying the interval between retries.

@vszakats How will that flag fix #9 as you suggested in your original post? The failures are not 4xx or 5xx.

@vszakats
Copy link
Author

It's the laziest fix to offer some kind of retry. The reasons for a failure can be many. I delete the reference to #9.

But, since this doesn't work anyway due to lack of support in PowerShell, I guess a better approach would be using curl with --retry-all-errors or similar.

@vszakats vszakats closed this Mar 26, 2025
@vszakats vszakats deleted the retry branch March 26, 2025 14:29
@jon-turney
Copy link
Member

Please review #26

@gstrauss
Copy link
Contributor

Well, I'm not a windows expert here.

With powershell 6 and 7, powershell was renamed to pwsh.

With some more testing, I found that if your PR changed shell: powershell to shell: pwsh, then you could use -MaximumRetryCount 3 so I think that is a worthwhile PR to change to use pwsh.

@gstrauss
Copy link
Contributor

gstrauss commented Mar 26, 2025

@jon-turney should this PR be resurrected? Or would you prefer a separate PR to change shell: powershell to shell: pwsh?

@vszakats
Copy link
Author

@jon-turney: Thanks for #26. LGTM, made a comment there.

gstrauss added a commit to gstrauss/lighttpd1.4 that referenced this pull request Mar 27, 2025
lighttpd-git pushed a commit to lighttpd/lighttpd1.4 that referenced this pull request Mar 27, 2025
@jon-turney
Copy link
Member

should this PR be resurrected

The documentation seems to indicate that MaximumRetryCount doesn't do anything on socket connection refused or timeout, so it's effective a worthless option.

So, thanks for the PR, but this seems hobbled into uselessness by choices made in pwsh. ☹️

@gstrauss
Copy link
Contributor

gstrauss commented Apr 7, 2025

The documentation seems to indicate that MaximumRetryCount doesn't do anything on socket connection refused or timeout, so it's effective a worthless option.

Yes. I was able to test this a few days ago when retrieving setup.exe from the mirror was for some reason slow. Even using pwsh with Invoke-WebRequest -MaximumRetryCount 3 ended up failing fairly quickly, i.e. it did not help much, if at all. I'll check (in a different PR) to see if the timeouts can be increased.

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.

3 participants