Skip to content

Conversation

stevensJourney
Copy link
Collaborator

Overview

When disconnecting and connecting frequently, it is currently possible for the Rust sync clients to get locked in a frozen state if the StreamingSyncClient is disconnected/aborted before it has connected.

This can happen if:

  • The client is triggered for a connect
  • A disconnect is requested shortly after
  • The StreamingSyncImplementation's AbortController is marked as aborted, but we nest the AbortController here.
  • For WebSocket requests, we usually check if the provided AbortSignal has been aborted before making the request (and we throw), but due to the wrapped controller used in the Rust implementation we don't detect that the wrapped controller has been aborted. The wrapped controller will also never be aborted since the upstream controller won't emit the aborted event again (since it was aborted before)
  • This causes the Rust client to remain connected. The ConnectionManager's disconnectingPromise never resolves, which causes a shared sync implementation to be frozen.

This checks the upstream AbortSignal before wrapping it. The abort is propagated by throwing a AbortOperation.

This could also have happened with the HTTP connection method. A check has been added there also.

Copy link

changeset-bot bot commented Aug 28, 2025

🦋 Changeset detected

Latest commit: 2f6153c

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

This PR includes changesets to release 8 packages
Name Type
@powersync/common Patch
@powersync/adapter-sql-js 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

@stevensJourney stevensJourney marked this pull request as ready for review August 28, 2025 09:21
Copy link
Contributor

@simolus3 simolus3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, thanks!

@stevensJourney stevensJourney merged commit 876c550 into main Aug 28, 2025
10 checks passed
@stevensJourney stevensJourney deleted the rust-disconnect branch August 28, 2025 09:39
whygee-dev pushed a commit to whygee-dev/powersync-js that referenced this pull request Oct 18, 2025
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