From c906af5bec4af9912152154aba8b96e7b7a24e70 Mon Sep 17 00:00:00 2001 From: bc547 Date: Sat, 23 Mar 2024 10:05:28 +0100 Subject: [PATCH] Make autoSync more robust for network errors Catch uncaught error in autoSync that caused autoSync to stop syncing --- .../src/services/configSync.service.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tabby-settings/src/services/configSync.service.ts b/tabby-settings/src/services/configSync.service.ts index fdd5efec..b811c9c0 100644 --- a/tabby-settings/src/services/configSync.service.ts +++ b/tabby-settings/src/services/configSync.service.ts @@ -184,13 +184,17 @@ export class ConfigSyncService { private async autoSync () { while (true) { - if (this.isEnabled() && this.config.store.configSync.auto) { - const cfg = await this.getConfig(this.config.store.configSync.configID) - if (new Date(cfg.modified_at) > this.lastRemoteChange) { - this.logger.info('Remote config changed, downloading') - this.download() - this.lastRemoteChange = new Date(cfg.modified_at) + try { + if (this.isEnabled() && this.config.store.configSync.auto) { + const cfg = await this.getConfig(this.config.store.configSync.configID) + if (new Date(cfg.modified_at) > this.lastRemoteChange) { + this.logger.info('Remote config changed, downloading') + this.download() + this.lastRemoteChange = new Date(cfg.modified_at) + } } + } catch (error) { + this.logger.debug("Recovering from autoSync network error") } await new Promise(resolve => setTimeout(resolve, 60000)) }