From 58e9ac2f7a3f4164bbffa1c19f02fc8984c7086a Mon Sep 17 00:00:00 2001 From: Garvit Surana <251430630+garvitsurana271@users.noreply.github.com> Date: Sun, 22 Nov 2026 10:09:14 +0000 Subject: [PATCH] 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 --- crates/stela-runtime/src/platform/net/ranges.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/crates/stela-runtime/src/platform/net/ranges.rs b/crates/stela-runtime/src/platform/net/ranges.rs index e719c21045..fb720e1539 100644 --- a/crates/stela-runtime/src/platform/net/ranges.rs +++ b/crates/stela-runtime/src/platform/net/ranges.rs @@ -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 Ranges { 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"));