Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Cap launch ping at 5s to keep slow networks from blocking app boot

Barnabas07dacea79230
diff --git a/lib/providers/auth_provider.dart b/lib/providers/auth_provider.dart
index 1118c51e..6a594cd9 100644
--- a/lib/providers/auth_provider.dart
+++ b/lib/providers/auth_provider.dart
@@ -169,7 +169,12 @@ class AuthProvider extends ChangeNotifier {
}
if (!reachable) {
debugPrint('[Auth] pinging remote server... (${sw.elapsedMilliseconds}ms)');
- reachable = await ApiService.pingServer(savedUrl, customHeaders: _customHeaders);
+ // Cap at 5s so a silently-dropping reverse proxy or dead network
+ // path doesn't hold up app launch. The health-check timer will
+ // re-probe every 60s once we're past startup, so a transient
+ // false-offline self-corrects quickly.
+ reachable = await ApiService.pingServer(savedUrl, customHeaders: _customHeaders)
+ .timeout(const Duration(seconds: 5), onTimeout: () => false);
debugPrint('[Auth] remote ping result: reachable=$reachable (${sw.elapsedMilliseconds}ms)');
}
_serverReachable = reachable;