fix: wait for pending transactions before db close

This was triggered by some archive decryption test I was writing and
possibly also is triggered in production a few times. Waiting for
running transactions to complete before closing sounds sensible.
This commit is contained in:
Nicolas Werner 2024-09-17 19:10:55 +02:00
parent 12f45e7687
commit fec258ef12
No known key found for this signature in database
GPG Key ID: B38119FF80087618
2 changed files with 3 additions and 2 deletions

View File

@ -80,7 +80,8 @@ class BoxCollection with ZoneTransactionMixin {
Future<void> close() async {
assert(_txnCache == null, 'Database closed while in transaction!');
return _db.close();
// Note, zoneTransaction and txnCache are different kinds of transactions.
return zoneTransaction(() async => _db.close());
}
@Deprecated('use collection.deleteDatabase now')

View File

@ -66,7 +66,7 @@ class BoxCollection with ZoneTransactionMixin {
},
);
Future<void> close() => _db.close();
Future<void> close() => zoneTransaction(() => _db.close());
@Deprecated('use collection.deleteDatabase now')
static Future<void> delete(String path, [dynamic factory]) =>