Skip to content

Commit

Permalink
Shortcircuit sync loop if we've requested to stop syncing (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewFerr committed Jun 29, 2023
2 parents fbec61f + 7902671 commit 6b37f16
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/MatrixClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,11 @@ export class MatrixClient extends EventEmitter {
await Promise.resolve(this.storage.setSyncToken(token));
}
} catch (e) {
// If we've requested to stop syncing, don't bother checking the error.
if (this.stopSyncing) {
LogService.info("MatrixClientLite", "Client stop requested - cancelling sync");
return;
}
LogService.error("MatrixClientLite", "Error handling sync " + extractRequestError(e));
const backoffTime = SYNC_BACKOFF_MIN_MS + Math.random() * (SYNC_BACKOFF_MAX_MS - SYNC_BACKOFF_MIN_MS);
LogService.info("MatrixClientLite", `Backing off for ${backoffTime}ms`);
Expand Down

0 comments on commit 6b37f16

Please sign in to comment.