Fix sync client dropping lines#960
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: 4925506 The changes in this PR will be included in the next version bump. This PR includes changesets to release 8 packages
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 |
Contributor
|
@simolus3 Do you know when the issue has been introduced? Just wondering if it has always been present if the Rust sync client was used, or if it was a regression introduced at some point. |
Contributor
Author
stevensJourney
approved these changes
May 13, 2026
Contributor
Author
|
The isolated demos check fails because of pnpm11. There's an open PR for that, I'll merge this with failing checks because we likely want to release this first. |
Stvad
added a commit
to Stvad/knowledge-medium
that referenced
this pull request
May 14, 2026
Backports powersync-ja/powersync-js#960. Without it, ~1 in 3 local writes triggers a checksum mismatch and a full bucket wipe (see #954). patch-package applies the diff on every install so CI ships it too; remove once a release with the upstream fix is published.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A race condition in
injectable(used by the Rust sync client to forward sync lines along with local events like a completed upload) could cause sync lines to be ignored. In particular, a local write + sync caused events where thedataline in acheckpoint_diff,data,checkpoint_completegot dropped, causing checksum verification errors.The issue is caused by this sequence of events:
injectablestream, causing it to fetch a sync line from the source upstream (waiteris set,pendingSourceEventis null).inject, making the initial event complete (waiteris now null).next()again.pendingSourceEventis still null because the initial source event has not completed, so we try to callsource.next()again. Async iterators aren't meant to be used concurrently like this, andresolveWaitermay loose events since there is only one slot for a pending source event once the two complete.The fix is to not call
source.next()again, I've manually verified this in Steven's convex demo where this reproduces consistently.Product visibility
This doesn't change anything that needs to be documented, but I'm adding the label due to the severity of the issue and in case we get addititional reports for this.
AI usage disclaimer
The issue was found by Claude after manual testing; it also generated the fix and test. I've manually verified the fix in the convex demo.
Closes #954.