Skip to content

Commit 8aebc8e

Browse files
Half-ShotAndrewFerrturt2live
authored
Shortcircuit sync loop if we've requested to stop syncing (turt2live#323)
* Shortcircuit sync loop if we've requested to stop syncing * Update src/MatrixClient.ts Co-authored-by: Andrew Ferrazzutti <andrewf@element.io> * Apply suggestions from code review --------- Co-authored-by: Andrew Ferrazzutti <andrewf@element.io> Co-authored-by: Travis Ralston <travpc@gmail.com>
1 parent 9422886 commit 8aebc8e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/MatrixClient.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,12 @@ export class MatrixClient extends EventEmitter {
721721
await Promise.resolve(this.storage.setSyncToken(token));
722722
}
723723
} catch (e) {
724+
// If we've requested to stop syncing, don't bother checking the error.
725+
if (this.stopSyncing) {
726+
LogService.info("MatrixClientLite", "Client stop requested - cancelling sync");
727+
return;
728+
}
729+
724730
LogService.error("MatrixClientLite", "Error handling sync " + extractRequestError(e));
725731
const backoffTime = SYNC_BACKOFF_MIN_MS + Math.random() * (SYNC_BACKOFF_MAX_MS - SYNC_BACKOFF_MIN_MS);
726732
LogService.info("MatrixClientLite", `Backing off for ${backoffTime}ms`);

0 commit comments

Comments
 (0)