From 9f3c14ab1ecf7a3f9985e38e7400c29de1affff4 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 3d942696..f88819c8 100644 --- a/internal/user/user.go +++ b/internal/user/user.go @@ -647,6 +647,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. @@ -691,6 +693,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.