From 20d83dd47634b377488ef76cde8c68a09017bdaa Mon Sep 17 00:00:00 2001 From: James Houlahan Date: Tue, 7 Feb 2023 09:59:46 +0100 Subject: [PATCH] fix(GODT-2327): Loop to retry until sync has complete --- internal/user/user.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/internal/user/user.go b/internal/user/user.go index 3b1c168d..58bfcd09 100644 --- a/internal/user/user.go +++ b/internal/user/user.go @@ -194,9 +194,17 @@ func New( return } - if err := user.doSync(ctx); err != nil { - user.log.WithError(err).Error("Failed to sync, will retry later") - time.AfterFunc(SyncRetryCooldown, user.goSync) + for { + if err := ctx.Err(); err != nil { + user.log.WithError(err).Error("Sync aborted") + return + } else if err := user.doSync(ctx); err != nil { + user.log.WithError(err).Error("Failed to sync, will retry later") + time.Sleep(SyncRetryCooldown) + } else { + user.log.Info("Sync complete, starting API event stream") + return + } } })