Skip to content

Commit f3e0874

Browse files
authored
Pass --speed-limit and --speed-time when passing --retry (#1637)
Some users report that the interior curl request stalls ~forever. This patch sets a low speed-limit of 20% of modern DSL throughput. If a user's download rate is just below the limit, it will take approximately five minutes to download. When the speed limit trips, it will retry up to three times. Hopefully this doesn't impact users, but if you are impacted, please open a ticket.
1 parent dcd108a commit f3e0874

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

nix-installer.sh

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ downloader() {
280280
if [ "$1" = --check ]; then
281281
need_cmd "$_dld"
282282
elif [ "$_dld" = curl ]; then
283-
check_curl_for_retry_support
283+
check_curl_for_retry_and_speed_limit_support
284284
_retry="$RETVAL"
285285
get_ciphersuites_for_curl
286286
_ciphersuites="$RETVAL"
@@ -402,16 +402,25 @@ check_help_for() {
402402
}
403403

404404
# Check if curl supports the --retry flag, then pass it to the curl invocation.
405-
check_curl_for_retry_support() {
405+
# Note that --speed-limit and --speed-time were in the very first commit of curl.
406+
# So this should be pretty much ubiquitously safe.
407+
check_curl_for_retry_and_speed_limit_support() {
406408
local _retry_supported=""
409+
407410
# "unspecified" is for arch, allows for possibility old OS using macports, homebrew, etc.
408-
if check_help_for "notspecified" "curl" "--retry"; then
409-
_retry_supported="--retry 3"
411+
if check_help_for "notspecified" "curl" "--retry" \
412+
&& check_help_for "notspecified" "curl" "--speed-limit" \
413+
&& check_help_for "notspecified" "curl" "--speed-time"; then
414+
415+
# 250000 is approximately 20% of the bandwidth of typical DSL
416+
# these limits mean users below these limits will see failures.
417+
# I don't believe we have any users like this, and if we do -- please open a ticket.
418+
_retry_supported="--retry 3 --speed-limit 250000 --speed-time 15"
410419
fi
411-
412420
RETVAL="$_retry_supported"
413421
}
414422

423+
415424
# Return cipher suite string specified by user, otherwise return strong TLS 1.2-1.3 cipher suites
416425
# if support by local tools is detected. Detection currently supports these curl backends:
417426
# GnuTLS and OpenSSL (possibly also LibreSSL and BoringSSL). Return value can be empty.

0 commit comments

Comments
 (0)