Skip to content

Commit 6a773d7

Browse files
committed
Fix crud throttling issues.
1 parent 39c99b2 commit 6a773d7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/powersync/lib/src/database/native/native_powersync_database.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,8 @@ Future<void> _powerSyncDatabaseIsolate(
363363
Set<String> updatedTables = {};
364364

365365
void maybeFireUpdates() {
366-
if (updatedTables.isNotEmpty) {
366+
// Only fire updates when we're not in a transaction
367+
if (updatedTables.isNotEmpty && db?.autocommit == true) {
367368
upstreamDbClient.fire(UpdateNotification(updatedTables));
368369
updatedTables.clear();
369370
updateDebouncer?.cancel();
@@ -375,7 +376,7 @@ Future<void> _powerSyncDatabaseIsolate(
375376
updatedTables.add(event.tableName);
376377

377378
updateDebouncer ??=
378-
Timer(const Duration(milliseconds: 10), maybeFireUpdates);
379+
Timer(const Duration(milliseconds: 1), maybeFireUpdates);
379380
});
380381
}, (error, stack) {
381382
// Properly dispose the database if an uncaught error occurs.

0 commit comments

Comments
 (0)