From 888c97d45fd9a2e5b5fb5df5857b94bf3a1feeb1 Mon Sep 17 00:00:00 2001 From: Half-Shot Date: Mon, 5 Jun 2023 11:40:08 +0100 Subject: [PATCH 1/2] Shortcircuit sync loop if we've requested to stop syncing --- src/MatrixClient.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/MatrixClient.ts b/src/MatrixClient.ts index 47dc6b72..d0324571 100644 --- a/src/MatrixClient.ts +++ b/src/MatrixClient.ts @@ -721,6 +721,10 @@ 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) { + 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`); From 79026712f70ac7beee8ef36bb3b0c6e7a94eeb86 Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Thu, 29 Jun 2023 13:49:15 +0100 Subject: [PATCH 2/2] Update src/MatrixClient.ts Co-authored-by: Andrew Ferrazzutti --- src/MatrixClient.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/MatrixClient.ts b/src/MatrixClient.ts index d0324571..281fe444 100644 --- a/src/MatrixClient.ts +++ b/src/MatrixClient.ts @@ -723,6 +723,7 @@ export class MatrixClient extends EventEmitter { } 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));