Skip to content

Align crud uploads with Dart implementation#977

Merged
simolus3 merged 6 commits into
mainfrom
crud-upload-on-connect
May 26, 2026
Merged

Align crud uploads with Dart implementation#977
simolus3 merged 6 commits into
mainfrom
crud-upload-on-connect

Conversation

@simolus3
Copy link
Copy Markdown
Contributor

@simolus3 simolus3 commented May 25, 2026

The Dart SDK invokes the CRUD upload method of the configured backend connector at least once per connect() call, even if we can't connect to the streaming sync endpoint. We want the same behavior in the JS SDK, and this PR adds that.

To make the implementation easier to reason about, this also aligns the implementation with the Dart SDK:

  • We call crudUploadLoop in connect(), it takes a scoped abort signal now to abort along with the corresponding streamingSync() call after a disconnect.
  • Instead of invoking uploads directly in an event handler, we create something resembling a stream controller to dispatch and throttle events on the consuming side.

Note that there are still some fishy things going on here, e.g. we break out of the _uploadAllCrud() loop if there's an error and we're not connected. The Dart SDK does the same, and this PR is still an improvement, but we should probably spec out how we actually want the upload flow to behave before applying this to other SDKs.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 25, 2026

🦋 Changeset detected

Latest commit: 1cffb2e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@powersync/common Patch
@powersync/node Patch
@powersync/op-sqlite Patch
@powersync/react-native Patch
@powersync/tanstack-react-query Patch
@powersync/web Patch
@powersync/diagnostics-app Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@simolus3 simolus3 marked this pull request as ready for review May 25, 2026 18:59
@simolus3 simolus3 requested a review from stevensJourney May 25, 2026 18:59
Comment thread packages/common/src/utils/async.ts Outdated
@simolus3
Copy link
Copy Markdown
Contributor Author

It looks like the Tauri integration tests are broken (timeouts without a message). They pass locally though, so I'll merge this and investigate those failures on another branch.

@simolus3 simolus3 merged commit 6bbaefe into main May 26, 2026
15 of 17 checks passed
@simolus3 simolus3 deleted the crud-upload-on-connect branch May 26, 2026 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants