From 45b12811b01c780b44eced259df3289650fd41f7 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Tue, 10 Mar 2026 00:17:22 +0100 Subject: [PATCH] Updater: don't immediately retry if check fails If something goes wrong, maybe it's best not to DoS the update server. Instead back off gradually and then go into the usual sleep loop. Signed-off-by: Jason A. Donenfeld --- ui/src/main/java/com/wireguard/android/updater/Updater.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ui/src/main/java/com/wireguard/android/updater/Updater.kt b/ui/src/main/java/com/wireguard/android/updater/Updater.kt index 4a3ee505..fbf265e0 100644 --- a/ui/src/main/java/com/wireguard/android/updater/Updater.kt +++ b/ui/src/main/java/com/wireguard/android/updater/Updater.kt @@ -410,18 +410,24 @@ object Updater { return@launch var waitTime = 15 + var exceptionCount = 0 while (true) { try { - val update = checkForUpdates() ?: continue + val update = checkForUpdates() ?: throw Exception("No updates found") if (update.version > CURRENT_VERSION) { Log.i(TAG, "Update available: ${update.version}") UserKnobs.setUpdaterNewerVersionSeen(update.version.toString()) return@launch } } catch (_: Throwable) { + if (++exceptionCount <= 6) { + delay((exceptionCount * 8).seconds) + continue + } } delay(waitTime.minutes) waitTime = 45 + exceptionCount = 0 } }