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
Half-Shot authored Jun 29, 2023
2 parents bb93184 + 7902671 commit e220801
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 e220801

Please sign in to comment.