nuke-build / nuke

🏗 The AKEless Build System for C#/.NET
https://nuke.build
MIT License
3.07k stars 367 forks source link

HttpTasks.HttpDownloadFileAsync times out for long running downloads #1439

Closed Danielku15 closed 1 month ago

Danielku15 commented 1 month ago

Usage Information

8.1.2, net8.0, Windows

Description

The default behavior of HttpClient is to complete a HTTP request when the whole response is completed.

The operation should complete after reading the entire response including the content. https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcompletionoption?view=net-8.0#fields

https://github.com/nuke-build/nuke/blob/c8d9236a19446f15c1b6b2e22a6f4b4f474d20ca/source/Nuke.Common/IO/HttpTasks.cs#L58

https://github.com/dotnet/runtime/blob/529be78d1b71a8dac510ddcc14d37ae6c244b5f7/src/libraries/System.Net.Http/src/System/Net/Http/HttpClient.cs#L22

If downloads take longer than the timeout (default 5 secs or customized via clientConfigurator the downloads times out even though the download is still progressing.

Reproduction Steps

  1. HttpTasks.HttpDownloadFile("https://releases.ubuntu.com/24.04.1/ubuntu-24.04.1-desktop-amd64.iso, RootDirectory / "ubuntu.iso")`

Expected Behavior

  1. The 5 second timeout should only be considered for the HTTP request, there should either be a higher or no timeout for the actual file download. Or technically said: Nuke should start the download via httpClient.GetAsync(uri, HttpCompletionOption.ResponseHeadersRead).

Actual Behavior

  1. Downloads timeout after 5 seconds.

Regression?

No response

Known Workarounds

Increase the timeout of the HTTP client and accept the fact that the whole file will be read before progressing (instead of streaming the download to disk).

Could you help with a pull-request?

Yes

matkoch commented 1 month ago

I recommend using Flur. HttpTasks was a mistake.