File tree Expand file tree Collapse file tree
packages/powersync/lib/src/sync Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -143,10 +143,11 @@ class StreamingSyncImplementation implements StreamingSync {
143143 Future <void > streamingSync () async {
144144 assert (_abort == null );
145145 final abort = _abort = AbortController ();
146+ Future <void > crudLoop;
146147
147148 try {
148149 clientId = await adapter.getClientId ();
149- _crudLoop ().onError ((error, stackTrace) {
150+ crudLoop = _crudLoop ().onError ((error, stackTrace) {
150151 if (aborted && error is AbortException ) return ;
151152
152153 logger.warning ('Error in crud upload loop' , error, stackTrace);
@@ -181,6 +182,10 @@ class StreamingSyncImplementation implements StreamingSync {
181182 await _delayRetry ();
182183 }
183184 }
185+
186+ // Wait for the crud loop to abort as well, this mainly guarantees that we
187+ // don't leave any trailing async tasks behind.
188+ await crudLoop;
184189 } finally {
185190 abort.completeAbort ();
186191 }
You can’t perform that action at this time.
0 commit comments