@@ -619,10 +619,9 @@ The next upload iteration will be delayed.`);
619619 this . options . adapter . startSession ( ) ;
620620 let [ req , bucketMap ] = await this . collectLocalBucketState ( ) ;
621621
622- // These are compared by reference
623622 let targetCheckpoint : Checkpoint | null = null ;
624- let validatedCheckpoint : Checkpoint | null = null ;
625- let appliedCheckpoint : Checkpoint | null = null ;
623+ // A checkpoint that has been validated but not applied (e.g. due to pending local writes)
624+ let pendingValidatedCheckpoint : Checkpoint | null = null ;
626625
627626 const clientId = await this . options . adapter . getClientId ( ) ;
628627 const usingFixedKeyFormat = await this . requireKeyFormat ( false ) ;
@@ -686,10 +685,10 @@ The next upload iteration will be delayed.`);
686685 }
687686
688687 if ( 'crud_upload_completed' in line ) {
689- if ( validatedCheckpoint != null ) {
690- const { applied, endIteration } = await this . applyCheckpoint ( validatedCheckpoint ) ;
688+ if ( pendingValidatedCheckpoint != null ) {
689+ const { applied, endIteration } = await this . applyCheckpoint ( pendingValidatedCheckpoint ) ;
691690 if ( applied ) {
692- appliedCheckpoint = validatedCheckpoint ;
691+ pendingValidatedCheckpoint = null ;
693692 } else if ( endIteration ) {
694693 break ;
695694 }
@@ -729,10 +728,9 @@ The next upload iteration will be delayed.`);
729728 const result = await this . applyCheckpoint ( targetCheckpoint ! ) ;
730729 if ( result . endIteration ) {
731730 return ;
732- } else if ( result . applied ) {
733- appliedCheckpoint = targetCheckpoint ;
731+ } else if ( ! result . applied ) {
732+ pendingValidatedCheckpoint = targetCheckpoint ;
734733 }
735- validatedCheckpoint = targetCheckpoint ;
736734 } else if ( isStreamingSyncCheckpointPartiallyComplete ( line ) ) {
737735 const priority = line . partial_checkpoint_complete . priority ;
738736 this . logger . debug ( 'Partial checkpoint complete' , priority ) ;
0 commit comments