JustinGrote / ModuleFast

A "fast and loose" way to install modules from Powershell Gallery quickly. Meant for CICD, not production
Other
74 stars 5 forks source link

Allow Configurable Timeout for HTTPS Sessions #85

Closed jbogard closed 2 weeks ago

jbogard commented 2 months ago

I'm trying to run in Azure DevOps environments and getting frequent timeouts:

Install-ModuleFast : The request was canceled due to the configured HttpClient.Timeout of 30 seconds elapsing.

The script I'm running:

iwr bit.ly/modulefast | iex

Install-ModuleFast 'Az','Az.Accounts','SqlServer' -CI

It fails intermittently locally as well with timeout errors. Is it possible to configure this timeout?

JustinGrote commented 2 months ago

So ModuleFast doesn't have much error correction at the moment. If one of your requests doesn't receive a response, it doesn't attempt a retry, it simply times out, so if your network is not stable then it's not going to be a good solution. I do hope to add some basic retry logic but it's difficult given the optimized task nature and still using PowerShell. Thanks for the report!

JustinGrote commented 2 months ago

fails intermittently locally as well with timeout errors. Is it possible to configure this timeout?

The timeout should be configurable, but also, do you really need the entire Az module for your pipeline? If you choose a subset of modules it'll go way faster.

jbogard commented 2 months ago

Yes evidently the consensus on Twitter for the Az module is "don't install that". Dunno why so many tutorials suggested that!

When I just used the modules I actually needed, it went just fine.

JustinGrote commented 2 months ago

@jbogard there is a known issue where the httpclient starts the timer from the point I create the task, and if you're on a slow system downloading a LOT of modules, that task can get "queued" and timeout before it even actually is downloading anything. Haven't found any way in httpclient to fix this directly, but I think the ThrottleLimit parameter can help.

jborean93 commented 3 weeks ago

Started to come across this in my GHA CI pipelines. A quick and dirty fix would be to expose the TimeOut value as a parameter on Install-ModuleFast so https://github.com/JustinGrote/ModuleFast/blob/13a69aac16d6a9613dadd504865c185c581a0d71/ModuleFast.psm1#L461 is not hardcoded and we can just increase it a bit.

Going forward a retry mechanism would be great or changing the defaults to the connect operation is 30 seconds but the subsequent reads after the socket is connected being more than 30 seconds might be ideal.