From 0236ea64b6de686db351560a3f15d6966a5816e9 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Fri, 24 May 2024 12:49:16 +0300 Subject: [PATCH] Add checkpoint for message handling taking long --- messagetracking.go | 3 +++ portal.go | 1 + 2 files changed, 4 insertions(+) diff --git a/messagetracking.go b/messagetracking.go index 3614c5d..44fb219 100644 --- a/messagetracking.go +++ b/messagetracking.go @@ -47,6 +47,7 @@ var ( errMediaConvertFailed = errors.New("failed to convert media") errMediaReuploadFailed = errors.New("failed to upload media to google") errEchoTimeout = errors.New("remote echo timeout") + errHandlingTakingLong = errors.New("message handling is taking long") errIncorrectUser = errors.New("incorrect user") errNotLoggedIn = errors.New("not logged in") @@ -99,6 +100,8 @@ func errorToStatusReason(err error) (reason event.MessageStatusReason, status ev return event.MessageStatusTooOld, event.MessageStatusRetriable, false, true, "handling the message took too long and was cancelled" case errors.Is(err, errEchoTimeout): return event.MessageStatusTooOld, event.MessageStatusRetriable, false, true, "phone has not confirmed message delivery" + case errors.Is(err, errHandlingTakingLong): + return event.MessageStatusTooOld, event.MessageStatusRetriable, false, true, "sending the message is taking long; is your phone online?" case errors.Is(err, errTargetNotFound): return event.MessageStatusGenericError, event.MessageStatusFail, true, false, "" case errors.As(err, &ose): diff --git a/portal.go b/portal.go index 0fa6f3a..95f8571 100644 --- a/portal.go +++ b/portal.go @@ -374,6 +374,7 @@ func (portal *Portal) handleMatrixMessageLoopItem(msg PortalMatrixMessage) { portal.zlog.Error(). Stringer("event_id", msg.evt.ID). Msg("Matrix event handling is taking over a minute, unblocking loop") + go portal.bridge.SendMessageCheckpoint(msg.evt, status.MsgStepRemote, errHandlingTakingLong, status.MsgStatusTimeout, 0) } }