fix(auth): Improve token retrieval reliability on cold start

This commit is contained in:
cogwheel
2025-12-21 08:51:03 +05:30
parent 83c2e01528
commit d4a9b6863d
2 changed files with 49 additions and 2 deletions

View File

@@ -71,6 +71,17 @@ void main() {
synchronizable: false,
),
);
// Warm up secure storage on cold start. iOS Keychain access can be slow
// on first read, which causes race conditions where auth token returns
// null even when it exists. This pre-warms the keychain connection.
try {
await secureStorage
.read(key: '_warmup')
.timeout(const Duration(milliseconds: 500), onTimeout: () => null);
} catch (_) {
// Ignore warmup errors - this is best-effort
}
_startupTimeline!.instant('secure_storage_ready');
// Initialize Hive (now optimized with migration state caching)