@@ -342,17 +342,18 @@ export abstract class AbstractStreamingSyncImplementation
342342 let checkedCrudItem : CrudEntry | undefined ;
343343
344344 while ( true ) {
345- this . updateSyncStatus ( {
346- dataFlow : {
347- uploading : true
348- }
349- } ) ;
350345 try {
351346 /**
352347 * This is the first item in the FIFO CRUD queue.
353348 */
354349 const nextCrudItem = await this . options . adapter . nextCrudItem ( ) ;
355350 if ( nextCrudItem ) {
351+ this . updateSyncStatus ( {
352+ dataFlow : {
353+ uploading : true
354+ }
355+ } ) ;
356+
356357 if ( nextCrudItem . clientId == checkedCrudItem ?. clientId ) {
357358 // This will force a higher log level than exceptions which are caught here.
358359 this . logger . warn ( `Potentially previously uploaded CRUD entries are still present in the upload queue.
@@ -410,23 +411,15 @@ The next upload iteration will be delayed.`);
410411 this . abortController = controller ;
411412 this . streamingSyncPromise = this . streamingSync ( this . abortController . signal , options ) ;
412413
413- // Return a promise that resolves when the connection status is updated
414+ // Return a promise that resolves when the connection status is updated to indicate that we're connected.
414415 return new Promise < void > ( ( resolve ) => {
415416 const disposer = this . registerListener ( {
416- statusUpdated : ( update ) => {
417- // This is triggered as soon as a connection is read from
418- if ( typeof update . connected == 'undefined' ) {
419- // only concern with connection updates
420- return ;
421- }
422-
423- if ( update . connected == false ) {
424- /**
425- * This function does not reject if initial connect attempt failed.
426- * Connected can be false if the connection attempt was aborted or if the initial connection
427- * attempt failed.
428- */
417+ statusChanged : ( status ) => {
418+ if ( status . dataFlowStatus . downloadError != null ) {
429419 this . logger . warn ( 'Initial connect attempt did not successfully connect to server' ) ;
420+ } else if ( status . connecting ) {
421+ // Still connecting.
422+ return ;
430423 }
431424
432425 disposer ( ) ;
@@ -889,6 +882,10 @@ The next upload iteration will be delayed.`);
889882 ) ;
890883 }
891884
885+ // The rust client will set connected: true after the first sync line because that's when it gets invoked, but
886+ // we're already connected here and can report that.
887+ syncImplementation . updateSyncStatus ( { connected : true } ) ;
888+
892889 try {
893890 while ( ! controlInvocations . closed ) {
894891 const line = await controlInvocations . read ( ) ;
0 commit comments