Skip to content

Commit

Permalink
Make autoSync more robust for network errors
Browse files Browse the repository at this point in the history
Catch uncaught error in autoSync that caused autoSync to stop syncing
  • Loading branch information
bc547 committed Mar 23, 2024
1 parent 24c64a5 commit c906af5
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions tabby-settings/src/services/configSync.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Check failure on line 197 in tabby-settings/src/services/configSync.service.ts

View workflow job for this annotation

GitHub Actions / Lint

Strings must use singlequote
}
await new Promise(resolve => setTimeout(resolve, 60000))
}
Expand Down

0 comments on commit c906af5

Please sign in to comment.