Make autoSync more robust for network errors

Catch uncaught error in autoSync that caused autoSync to stop syncing
This commit is contained in:
bc547 2024-03-23 10:05:28 +01:00 committed by GitHub
parent 24c64a5e24
commit c906af5bec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -184,6 +184,7 @@ export class ConfigSyncService {
private async autoSync () { private async autoSync () {
while (true) { while (true) {
try {
if (this.isEnabled() && this.config.store.configSync.auto) { if (this.isEnabled() && this.config.store.configSync.auto) {
const cfg = await this.getConfig(this.config.store.configSync.configID) const cfg = await this.getConfig(this.config.store.configSync.configID)
if (new Date(cfg.modified_at) > this.lastRemoteChange) { if (new Date(cfg.modified_at) > this.lastRemoteChange) {
@ -192,6 +193,9 @@ export class ConfigSyncService {
this.lastRemoteChange = new Date(cfg.modified_at) this.lastRemoteChange = new Date(cfg.modified_at)
} }
} }
} catch (error) {
this.logger.debug("Recovering from autoSync network error")
}
await new Promise(resolve => setTimeout(resolve, 60000)) await new Promise(resolve => setTimeout(resolve, 60000))
} }
} }