@@ -410,23 +410,15 @@ The next upload iteration will be delayed.`);
410410 this . abortController = controller ;
411411 this . streamingSyncPromise = this . streamingSync ( this . abortController . signal , options ) ;
412412
413- // Return a promise that resolves when the connection status is updated
413+ // Return a promise that resolves when the connection status is updated to indicate that we're connected.
414414 return new Promise < void > ( ( resolve ) => {
415415 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- */
416+ statusChanged ( status ) {
417+ if ( status . dataFlowStatus . downloadError != null ) {
429418 this . logger . warn ( 'Initial connect attempt did not successfully connect to server' ) ;
419+ } else if ( status . connecting ) {
420+ // Still connecting.
421+ return ;
430422 }
431423
432424 disposer ( ) ;
@@ -928,16 +920,11 @@ The next upload iteration will be delayed.`);
928920 }
929921
930922 const info = instruction . UpdateSyncStatus . status ;
931- const lastStatus = syncImplementation . syncStatus ;
932923 const coreCompleteSync = info . priority_status . find ( ( s ) => s . priority == FULL_SYNC_PRIORITY ) ;
933924 const completeSync = coreCompleteSync != null ? coreStatusToJs ( coreCompleteSync ) : null ;
934925
935926 syncImplementation . updateSyncStatus ( {
936- // The first update to the connected field should only happen when it has really changed - there's a
937- // statusUpdated listener in connect() that will only make the promise complete once connected has changed.
938- // We only want to apply that workaround while we're connecting because it's only relevant in the initial
939- // connect call. Afterwards, we want to forward the sync status unchanged.
940- connected : lastStatus . connected == info . connected && info . connecting ? undefined : info . connected ,
927+ connected : info . connected ,
941928 connecting : info . connecting ,
942929 dataFlow : {
943930 downloading : info . downloading != null ,
0 commit comments