From c15917aba46d3eef84d14c0c6b645cb0b659e1b2 Mon Sep 17 00:00:00 2001 From: James Houlahan Date: Fri, 24 Feb 2023 16:02:15 +0100 Subject: [PATCH] fix(GODT-2404): Handle unexpected EOF When fetching too many attachment bodies at once, the read can fail with io.ErrUnexpectedEOF. In that case, we returun an error so the fetch is retried. --- internal/user/user.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/internal/user/user.go b/internal/user/user.go index 359836ff..5a690a36 100644 --- a/internal/user/user.go +++ b/internal/user/user.go @@ -650,6 +650,8 @@ func (user *User) doEventPoll(ctx context.Context) error { UserID: user.ID(), Error: err, }) + + return fmt.Errorf("failed to get event due to JSON issue: %w", err) } // If the error is a server-side issue, return error to retry later. @@ -694,6 +696,18 @@ func (user *User) doEventPoll(ctx context.Context) error { UserID: user.ID(), Error: err, }) + + return fmt.Errorf("failed to handle event due to JSON issue: %w", err) + } + + // If the error is an unexpected EOF, return error to retry later. + if errors.Is(err, io.ErrUnexpectedEOF) { + user.eventCh.Enqueue(events.UncategorizedEventError{ + UserID: user.ID(), + Error: err, + }) + + return fmt.Errorf("failed to handle event due to EOF: %w", err) } // If the error is a server-side issue, return error to retry later.