From 9c6be78b4cb69f07978b52b230e999ecb7a7ea24 Mon Sep 17 00:00:00 2001 From: James Houlahan Date: Mon, 6 Feb 2023 16:58:01 +0100 Subject: [PATCH] fix(GODT-2327): Don't retry with abortable context because it's canceled --- internal/bridge/imap.go | 2 +- internal/user/user.go | 10 +--------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/internal/bridge/imap.go b/internal/bridge/imap.go index 361e75d9..052eba57 100644 --- a/internal/bridge/imap.go +++ b/internal/bridge/imap.go @@ -140,7 +140,7 @@ func (bridge *Bridge) addIMAPUser(ctx context.Context, user *user.User) error { if err := user.ClearSyncStatus(); err != nil { return fmt.Errorf("failed to clear sync status: %w", err) } - + // Add the user back to the IMAP server. if isNew, err := bridge.imapServer.LoadUser(ctx, imapConn, gluonID, user.GluonKey()); err != nil { return fmt.Errorf("failed to add IMAP user: %w", err) diff --git a/internal/user/user.go b/internal/user/user.go index b500319c..3b1c168d 100644 --- a/internal/user/user.go +++ b/internal/user/user.go @@ -196,15 +196,7 @@ func New( if err := user.doSync(ctx); err != nil { user.log.WithError(err).Error("Failed to sync, will retry later") - - go func() { - select { - case <-ctx.Done(): - user.log.WithError(err).Warn("Aborting sync retry") - case <-time.After(SyncRetryCooldown): - user.goSync() - } - }() + time.AfterFunc(SyncRetryCooldown, user.goSync) } })