Skip to content

Commit 1c1dc10

Browse files
mugikhanrkistner
andauthored
Fix Future already completed when calling waitForFirstSync (#117)
* Ensure future is not completed * Bump version * Add changelog entry for issue 114. * Iterate through stream instead of listening to it * Fix changelog message --------- Co-authored-by: Ralf Kistner <ralf@journeyapps.com>
1 parent e4c8023 commit 1c1dc10

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

packages/powersync/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 1.5.2
2+
3+
- Refactor `waitForFirstSync()` to iterate through the stream and remove the use of a `Future`.
4+
- Fix sync connection not immediately closed when calling `db.disconnect()` (#114).
5+
16
## 1.5.1
27

38
- Adds a hasSynced flag to check if initial data has been synced.

packages/powersync/lib/src/powersync_database.dart

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,14 +197,11 @@ class PowerSyncDatabase with SqliteQueries implements SqliteConnection {
197197
if (currentStatus.hasSynced ?? false) {
198198
return;
199199
}
200-
final completer = Completer<void>();
201-
statusStream.listen((result) {
200+
await for (final result in statusStream) {
202201
if (result.hasSynced ?? false) {
203-
completer.complete();
202+
break;
204203
}
205-
});
206-
207-
return completer.future;
204+
}
208205
}
209206

210207
@override

packages/powersync/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: powersync
2-
version: 1.5.1
2+
version: 1.5.2
33
homepage: https://powersync.com
44
repository: https://github.com/powersync-ja/powersync.dart
55
description: PowerSync Flutter SDK - keep PostgreSQL databases in sync with on-device SQLite databases.

0 commit comments

Comments
 (0)