Skip to content

Commit 7fc3ed0

Browse files
authored
fix(supabase_flutter): Add timeout to Hive.openBox to fix hanging issue (supabase#799)
* fix: Add timeout to Hive.openBox to fix hanging issue * Update packages/supabase_flutter/lib/src/local_storage.dart
1 parent 059ab77 commit 7fc3ed0

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/supabase_flutter/lib/src/local_storage.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ class HiveLocalStorage extends LocalStorage {
8787
encryptionCipher = HiveAesCipher(base64Url.decode(encryptionKey!));
8888
}
8989
await Hive.initFlutter('auth');
90-
await Hive.openBox(_hiveBoxName, encryptionCipher: encryptionCipher);
90+
await Hive.openBox(_hiveBoxName, encryptionCipher: encryptionCipher)
91+
.timeout(const Duration(seconds: 1));
9192
}
9293

9394
@override
@@ -185,7 +186,12 @@ class MigrationLocalStorage extends LocalStorage {
185186
await Hive.initFlutter('auth');
186187
hiveLocalStorage = const HiveLocalStorage();
187188
await sharedPreferencesLocalStorage.initialize();
188-
await migrate();
189+
try {
190+
await migrate();
191+
} on TimeoutException {
192+
// Ignore TimeoutException thrown by Hive methods
193+
// https://github.com/supabase/supabase-flutter/issues/794
194+
}
189195
}
190196

191197
@visibleForTesting

0 commit comments

Comments
 (0)