Skip to content

Commit

Permalink
T-Defect: stop keep alive, when sync was stoped
Browse files Browse the repository at this point in the history
Signed-off-by: Malte Finsterwalder <[email protected]>
  • Loading branch information
Malte Finsterwalder committed Sep 12, 2023
1 parent f963ca5 commit 8a9e2ea
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1509,7 +1509,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
this.clientOpts.threadSupport = this.clientOpts.experimentalThreadSupport;
}

this.syncApi.sync();
this.syncApi.sync().catch((e) => logger.info("Sync startup aborted with an error:", e));

if (this.clientOpts.clientWellKnownPollPeriod !== undefined) {
this.clientWellKnownIntervalID = setInterval(() => {
Expand Down
11 changes: 11 additions & 0 deletions src/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1604,6 +1604,17 @@ export class SyncApi {
* @param connDidFail - True if a connectivity failure has been detected. Optional.
*/
private pokeKeepAlive(connDidFail = false): void {
if (!this.running) {
// we are in a keepAlive, retrying to connect, but the syncronization
// was stopped, so we are stopping the retry.
clearTimeout(this.keepAliveTimer);
if (this.connectionReturnedDefer) {
this.connectionReturnedDefer.reject("SyncApi.stop() was called");
this.connectionReturnedDefer = undefined;
}
return;
}

const success = (): void => {
clearTimeout(this.keepAliveTimer);
if (this.connectionReturnedDefer) {
Expand Down

0 comments on commit 8a9e2ea

Please sign in to comment.