Conversation
simolus3
marked this pull request as ready for review
September 18, 2026 14:05
simolus3
added this pull request to stack #42
September 18, 2026 15:48
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.
Spawning a background task (like the upload and download loops we spawn for connections) requires an asynchronous runtime, and the native SDK should support different option.
Currently, this is implemented by forcing the user to call
async_tasks().spawn_with()to spawn asynchronous tasks before connecting. This was intended for compatibility with embedded frameworks where spawning tasks dynamically is not possible.However, that greatly complicates the design of the sync client, as we need to start tasks that do nothing until connected, and need to handle reconnects as part of their state machine. This PR refactors the async setup to closer match what we have on our other SDKs:
connect()spawns the tasks,disconnect()waits for them to complete. This allows turning e.g. the download actor (250+ lines before) into a trivial loop (around 15 lines). This also makes it easier to spawn additional sync tasks (e.g. for the checkpoint request loop) in the future..This is a breaking change: Users need to construct their
PowerSyncEnvironmentdifferently to provide a mechanism to spawn tasks there.AI use: Reviewed with Claude code.