Repository navigation
be tries a download again when GitHub answers 504 (v0.12.0) - #11
Merged
Merged
Conversation
GitHub answers release downloads with a 504 now and then, most often to Actions runners, and one 504 failed the whole install. Every request be makes now goes through fetch, which retries a 408, 429, 500, 502, 503 or 504, a host that does not resolve or answer, a dropped connection or a timeout: up to 5 attempts, waiting 5, 10, 20 and 40 seconds. A 404 still fails at once. BE_DOWNLOAD_ATTEMPTS and BE_DOWNLOAD_RETRY_DELAY tune it; each retry is logged on stderr, --quiet or not. With wget, be makes one try at a time (--tries=1) and reads the status from --server-response, so a 503 is retried too and a 504 is not retried twenty times by wget as well. test/tests/retries.bats runs against flaky-mirror.js, a local server that answers 504 or drops the connection on demand. Co-Authored-By: Igor Lamos <igor@be.plus>
igorlamos
approved these changes
Nov 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Pull Request
Problem
GitHub answers release downloads with an HTTP 504 now and then, most often to Actions runners, and
bemade each request once, so a single 504 failed the whole install (be auto,be latest, …).actions/setup-noderides out the same 504s by waiting and trying again:Solution
Every request
bemakes now goes throughfetchinbin/be: the tarball's preflight (HEAD), itsSHA256SUMS, the tarball itself and the release index.Tried again: HTTP 408, 429, 500, 502, 503 and 504, a host that does not resolve or answer, a dropped connection, a timeout. Up to 5 attempts in all, waiting 5, 10, 20 and 40 seconds (about 75 seconds).
Not tried again: any other answer, such as a 404, which fails at once as before.
Settings:
BE_DOWNLOAD_ATTEMPTS(1 turns retrying off) andBE_DOWNLOAD_RETRY_DELAY(the first wait in seconds, doubling after that).be doctorshows both. A value that is not a whole number is refused.Log: each retry is a line on stderr, shown with
--quiettoo, and a final failure saysgave up:No half bodies: a release index or
SHA256SUMSis output only once an attempt succeeds, and each attempt starts the tarball file afresh.wget:
bemakes one try at a time (--tries=1) and reads the status from--server-response. GNU wget used to retry a 504 twenty times on its own but never a 503. BusyBox wget accepts both options.Tests
test/tests/retries.bats(13 tests) runs againsttest/tests/flaky-mirror.js, a small node server on 127.0.0.1 that answers 504 (or any status) or drops the connection, following a plan file per path, and logs every request. That way the tests check exactly how many requests each failure causes. One test hides curl from PATH to run the wget path; it skips where wget is missing.ubuntu-wgettest container (GNU wget 1.25, no curl), with nodejs added.be, the 9 retry tests fail and the 4 "fails at once" tests pass.The whole suite passes locally under bash 5 and bash 3.2. While this was written, GitHub answered beplus/cli release downloads with 504s on and off for about 45 minutes, and some spells lasted longer than the 75-second retry window. So the tests that download real releases (install-contents, install-options, install-versions, run-which, uninstall) passed only once GitHub was back. The same runs show the retries getting through two real failures, each of which used to fail the install:
A longer outage still fails after 5 attempts;
BE_DOWNLOAD_ATTEMPTS=8in CI stretches the window to about 10 minutes.Release
bin/bump minorand described it in CHANGELOG.mdbin/beis unchanged