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.
Overview
A bug was recently discovered where CRUD uploads would not retry (for a long time) after failing when using the WebSocket connection method.
This was due to a failed upload updating the connection status to
connected: false
. Following CRUD loop iterations would check the connection status and exit if not connected.The connection status is usually updated to
true
whenever a sync event is received from the PowerSync backend server. For the HTTP method keep-alive events are sent at regular intervals which will update the status back toconnected: true
. This is not the case for WebSockets as that method handles keep-alive events internally.This PR aligns the CRUD upload connection status logic with the Dart SDK. The connection status is not set to
false
if an upload fails. It is only set tofalse
if the connection to the backend server is closed. Reference here: https://github.com/powersync-ja/powersync.dart/blob/d812f78a5ae830e4ccdf29e1cb0a76aa27b01042/packages/powersync/lib/src/streaming_sync.dart#L102Testing
Unit tests have been added to ensure CRUD uploads are correctly triggered and retried.