fix(net): keep retrying a remote image range for about seven and a half minutes, its waits capped at 30 s, where a Wi-Fi extender that lost power ended an install at 97 % after a minute's seven attempts

This commit is contained in:
Garvit Surana committed 2026-11-22 10:09:14 +00:00
1 parent 951e92cf05
commit 58e9ac2f7a
1 file changed
+9 -3
@@ -40,8 +40,14 @@ pub const KEEP: usize = 8 << 20;
/// socket's worth), so its ring rarely grows.
pub const SLACK: usize = 8 << 20;
/// Consecutive failures of one range's progress before a read fails; the
/// waits between them double from a second, about a minute in all.
pub const ATTEMPTS: u32 = 7;
/// waits between them double from a second up to [`BACKOFF_CAP_MS`], about
/// seven and a half minutes in all: a router or Wi-Fi extender that loses
/// power and restarts takes two or three minutes, which a minute's budget
/// turned into a failed install at 97 %.
pub const ATTEMPTS: u32 = 20;
/// The longest wait between two attempts at one range, so that a network
/// that comes back is used again within half a minute.
pub const BACKOFF_CAP_MS: u64 = 30_000;
/// The longest one wait for an open range's next frame lasts.
pub const WAIT_US: u64 = 100_000;
/// The longest a bounded read waits for the network, and so holds the
@@ -324,7 +330,7 @@ impl<S: RangeSource> Ranges<S> {
looked = true;
let (failures, failed_at) = (self.streams[at].failures, self.streams[at].failed_at);
if failures > 0 {
let backoff = 1000 << (failures - 1);
let backoff = (1000u64 << (failures - 1).min(15)).min(BACKOFF_CAP_MS);
if self.source.millis().saturating_sub(failed_at) < backoff {
if self.bounded {
return Err(self.block("the range waits before it is asked again"));