File tree Expand file tree Collapse file tree 3 files changed +18
-1
lines changed
commonIntegrationTest/kotlin/com/powersync/sync
commonMain/kotlin/com/powersync/sync Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 11# Changelog
22
3+ ## 1.5.1 (unreleased)
4+
5+ * Fix issue in legacy sync client where local writes made offline could have their upload delayed
6+ until a keepalive event was received. This could also cause downloaded updates to be delayed even
7+ further until all uploads were
8+ completed.
9+
310## 1.5.0
411
512* Add ` PowerSyncDatabase.getCrudTransactions() ` , returning a flow of transactions. This is useful
Original file line number Diff line number Diff line change @@ -612,7 +612,6 @@ abstract class BaseSyncIntegrationTest(
612612 database.watch(" SELECT name FROM users" ) { it.getString(0 )!! }.testIn(scope)
613613 query.awaitItem() shouldBe listOf (" local write" )
614614
615- syncLines.send(SyncLine .KeepAlive (tokenExpiresIn = 1234 ))
616615 syncLines.send(
617616 SyncLine .FullCheckpoint (
618617 Checkpoint (
Original file line number Diff line number Diff line change @@ -536,9 +536,20 @@ internal class SyncStream(
536536 lateinit var receiveLines: Job
537537 receiveLines =
538538 scope.launch {
539+ var hadLine = false
539540 receiveTextLines(JsonUtil .json.encodeToJsonElement(req)).collect { value ->
540541 val line = JsonUtil .json.decodeFromString<SyncLine >(value)
541542
543+ if (! hadLine) {
544+ // Trigger a crud upload when receiving the first sync line: We could have
545+ // pending local writes made while disconnected, so in addition to listening on
546+ // updates to `ps_crud`, we also need to trigger a CRUD upload in some other
547+ // cases. We do this on the first sync line because the client is likely to be
548+ // online in that case.
549+ hadLine = true
550+ triggerCrudUploadAsync()
551+ }
552+
542553 state = handleInstruction(line, value, state)
543554
544555 if (state.abortIteration) {
You can’t perform that action at this time.
0 commit comments