Skip to content

Commit 5f877a3

Browse files
committed
Remove return value from sync iteration
1 parent 720ad7a commit 5f877a3

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

packages/common/src/client/sync/stream/AbstractStreamingSyncImplementation.ts

+10-20
Original file line numberDiff line numberDiff line change
@@ -441,16 +441,8 @@ The next upload iteration will be delayed.`);
441441
if (signal?.aborted) {
442442
break;
443443
}
444-
const { retry } = await this.streamingSyncIteration(nestedAbortController.signal, options);
445-
if (!retry) {
446-
/**
447-
* A sync error ocurred that we cannot recover from here.
448-
* This loop must terminate.
449-
* The nestedAbortController will close any open network requests and streams below.
450-
*/
451-
break;
452-
}
453-
// Continue immediately
444+
await this.streamingSyncIteration(nestedAbortController.signal, options);
445+
// Continue immediately, streamingSyncIteration will wait before completing if necessary.
454446
} catch (ex) {
455447
/**
456448
* Either:
@@ -508,8 +500,8 @@ The next upload iteration will be delayed.`);
508500
protected async streamingSyncIteration(
509501
signal: AbortSignal,
510502
options?: PowerSyncConnectionOptions
511-
): Promise<{ retry?: boolean }> {
512-
return await this.obtainLock({
503+
): Promise<void> {
504+
await this.obtainLock({
513505
type: LockType.SYNC,
514506
signal,
515507
callback: async () => {
@@ -559,7 +551,7 @@ The next upload iteration will be delayed.`);
559551
const line = await stream.read();
560552
if (!line) {
561553
// The stream has closed while waiting
562-
return { retry: true };
554+
return;
563555
}
564556

565557
// A connection is active and messages are being received
@@ -591,7 +583,7 @@ The next upload iteration will be delayed.`);
591583
} else if (isStreamingSyncCheckpointComplete(line)) {
592584
const result = await this.applyCheckpoint(targetCheckpoint!, signal);
593585
if (result.endIteration) {
594-
return { retry: true };
586+
return;
595587
} else if (result.applied) {
596588
appliedCheckpoint = targetCheckpoint;
597589
}
@@ -604,7 +596,7 @@ The next upload iteration will be delayed.`);
604596
// This means checksums failed. Start again with a new checkpoint.
605597
// TODO: better back-off
606598
await new Promise((resolve) => setTimeout(resolve, 50));
607-
return { retry: true };
599+
return;
608600
} else if (!result.ready) {
609601
// If we have pending uploads, we can't complete new checkpoints outside of priority 0.
610602
// We'll resolve this for a complete checkpoint.
@@ -681,7 +673,7 @@ The next upload iteration will be delayed.`);
681673
* (uses the same one), this should have some delay.
682674
*/
683675
await this.delayRetry();
684-
return { retry: true };
676+
return ;
685677
}
686678
this.triggerCrudUpload();
687679
} else {
@@ -699,9 +691,7 @@ The next upload iteration will be delayed.`);
699691
} else if (validatedCheckpoint === targetCheckpoint) {
700692
const result = await this.applyCheckpoint(targetCheckpoint!, signal);
701693
if (result.endIteration) {
702-
// TODO: Why is this one retry: false? That's the only change from when we receive
703-
// the line above?
704-
return { retry: false };
694+
return;
705695
} else if (result.applied) {
706696
appliedCheckpoint = targetCheckpoint;
707697
}
@@ -710,7 +700,7 @@ The next upload iteration will be delayed.`);
710700
}
711701
this.logger.debug('Stream input empty');
712702
// Connection closed. Likely due to auth issue.
713-
return { retry: true };
703+
return;
714704
}
715705
});
716706
}

0 commit comments

Comments
 (0)